diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..9482474cc12e4fc4c0bd5eaa1665f6575b349b9b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "de2a4ba1cd39cdd977548d94da03112df3c316b9e2ebce0115e104f82eeff17d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "492be585a058a3631e0b331afad30aff9c7199b8690d001a259334c9c024016a", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "d646e697c79226f71af6c3237b051bc1752870f3a39cc7116e4641926039be08", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "fba1562227e51ef44176e0af5866b30084e89e34", + "source_completion_sha256": "c4f70a6d59c4b6677e4f99f817db164d5e9ba3812b205ded396d485c95fa756a", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "b99d93e7d1ff633d09d46c2987f628b9957c2d97ac0aaf0f29923c7c795bf73a", + "is_fork": true, + "learner_path": "tasks/8c897387852803297e721ad7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/fba1562227e51ef44176e0af5866b30084e89e34/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9dccf3389c791cc31b743bcef019e52d81149a6224ee9201699f6ea2855e64da", + "provenance_path": "tasks/8c897387852803297e721ad7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "fba1562227e51ef44176e0af5866b30084e89e34", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2e76199a4675c36551a60af74281a718099c0598", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "task_sha256": "0f66703367994d529603408f2239290015020c9799d54c597935b6458c5e4a38", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..db889eeea18d26b6e0434255af8a8940672fca9f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/instruction.md @@ -0,0 +1,38 @@ +Schema key generation produces inconsistent results with unhashable attributes + +#### Description + +When generating schema keys for Marshmallow schemas that contain unhashable attributes (like lists or sets), the key generation function produces inconsistent results due to changes in how these attributes are processed and ordered. + +#### Steps/Code to Reproduce + +```python +from apispec.ext.marshmallow.common import make_schema_key +import marshmallow + +class TestSchema(marshmallow.Schema): + pass + +# Create schema instances with unhashable attributes +schema1 = TestSchema() +schema1.some_list = [1, 2, 3] + +schema2 = TestSchema() +schema2.some_list = [1, 2, 3] + +# These should produce the same key but don't +key1 = make_schema_key(schema1) +key2 = make_schema_key(schema2) + +print(f"Key 1: {key1}") +print(f"Key 2: {key2}") +print(f"Keys equal: {key1 == key2}") +``` + +The schema key generation is not producing consistent results for schemas with the same unhashable attributes, which can lead to duplicate schema definitions or incorrect schema resolution in the OpenAPI spec generation. + +This affects schema caching and component registration, potentially causing schemas that should be considered identical to be treated as different schemas. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..83b438da892db9aba5f30027dd47903dea2bd35d --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "2e76199a4675c36551a60af74281a718099c0598", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "fba1562227e51ef44176e0af5866b30084e89e34" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_common.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/common.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1020883, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "b99d93e7d1ff633d09d46c2987f628b9957c2d97ac0aaf0f29923c7c795bf73a", + "is_fork": true, + "learner_path": "tasks/8c897387852803297e721ad7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/fba1562227e51ef44176e0af5866b30084e89e34/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9dccf3389c791cc31b743bcef019e52d81149a6224ee9201699f6ea2855e64da", + "provenance_path": "tasks/8c897387852803297e721ad7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "fba1562227e51ef44176e0af5866b30084e89e34", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2e76199a4675c36551a60af74281a718099c0598", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "task_sha256": "0f66703367994d529603408f2239290015020c9799d54c597935b6458c5e4a38", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..cfd0be1c034c8bdcd39d06645853aa7a844c6cbd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "de2a4ba1cd39cdd977548d94da03112df3c316b9e2ebce0115e104f82eeff17d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/fba1562227e51ef44176e0af5866b30084e89e34/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "c4f70a6d59c4b6677e4f99f817db164d5e9ba3812b205ded396d485c95fa756a", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "b61faa8c3c2eb9eeb38d0e19ed494a3a219fb65ca5052bb75fd4495ccc303baf", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "b99d93e7d1ff633d09d46c2987f628b9957c2d97ac0aaf0f29923c7c795bf73a", + "is_fork": true, + "learner_path": "tasks/8c897387852803297e721ad7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/fba1562227e51ef44176e0af5866b30084e89e34/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9dccf3389c791cc31b743bcef019e52d81149a6224ee9201699f6ea2855e64da", + "provenance_path": "tasks/8c897387852803297e721ad7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "fba1562227e51ef44176e0af5866b30084e89e34", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2e76199a4675c36551a60af74281a718099c0598", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__sw95y0ye", + "task_sha256": "0f66703367994d529603408f2239290015020c9799d54c597935b6458c5e4a38", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..3bbf68399f202d08760161dcab64092ac8b06778 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/provided-gold.diff @@ -0,0 +1,41 @@ +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 874cc4c4c63773177ad06bd0d75fdf851eaadec4..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -119,14 +119,14 @@ + hash(attribute) + except TypeError: + # Unhashable iterable (list, set) +- attribute = list(attribute) # Change from frozenset to list +- modifiers.insert(0, attribute) # Change from append to insert at position 0 +- return tuple([schema.__class__, *reversed(modifiers)]) # Reverse the modifiers to their original order ++ attribute = frozenset(attribute) ++ modifiers.append(attribute) ++ return tuple([schema.__class__, *modifiers]) + + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -134,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -145,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cac15e517a755451aa518fdb353d75fb330665dc --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/solution/solve.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 874cc4c4c63773177ad06bd0d75fdf851eaadec4..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -119,14 +119,14 @@ + hash(attribute) + except TypeError: + # Unhashable iterable (list, set) +- attribute = list(attribute) # Change from frozenset to list +- modifiers.insert(0, attribute) # Change from append to insert at position 0 +- return tuple([schema.__class__, *reversed(modifiers)]) # Reverse the modifiers to their original order ++ attribute = frozenset(attribute) ++ modifiers.append(attribute) ++ return tuple([schema.__class__, *modifiers]) + + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -134,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -145,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..42dfc706fee3d625ebc82af446ab27db3de1b034 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:7964148413e9a3b3d4d831e52001cc91e4b4f88bec8f2c37affee6ee0a70d039" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..bc419a93635a00144faaaadf5d387aab3e2a26f5 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..88c74073e79a87dd8e11052bbb2a703c1117812c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/first-hunk-only.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 874cc4c4c63773177ad06bd0d75fdf851eaadec4..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -119,14 +119,14 @@ + hash(attribute) + except TypeError: + # Unhashable iterable (list, set) +- attribute = list(attribute) # Change from frozenset to list +- modifiers.insert(0, attribute) # Change from append to insert at position 0 +- return tuple([schema.__class__, *reversed(modifiers)]) # Reverse the modifiers to their original order ++ attribute = frozenset(attribute) ++ modifiers.append(attribute) ++ return tuple([schema.__class__, *modifiers]) + + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__sw95y0ye/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..b04fbab82e772ae677e93ec6060e6f5470d6be96 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "ec036495f24bdfc187e0075606bb1302ea32f79002282ab5f371e9977f625deb", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "dd3448c2eb820abf9ea82f0dabef7a7d301586f5320119e3512798095802fc0e", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "1f693dde54b5b5e7965825988a40442799c5b5cc6177da325e1e9b0244792f9a", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "04112d2ca1b131c061608fbb5c54b8e6189c39da", + "source_completion_sha256": "2ef340184cc1d9dfcd2cbc9bb05622525f817bc4a8e7dc4790232a42c6108cc0", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "58e450f9279684eedad9ec4d60c7843ea4f327a7b998dec18d6f185a07ef320a", + "is_fork": true, + "learner_path": "tasks/b491c0d8099392581ef57f79/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/04112d2ca1b131c061608fbb5c54b8e6189c39da/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9f63a2eaa5b2a77d4e0a4bd4406001c92d391be96abbf626ca370ad0f9e616ed", + "provenance_path": "tasks/b491c0d8099392581ef57f79/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "04112d2ca1b131c061608fbb5c54b8e6189c39da", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "24e2ab1be595b648135a3e70b7b5bc2784273669", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "task_sha256": "8c5ba9cccfd4e92bfe3ba985908417f3b97bd5e79e3b2b9fcd09d924b37c76b4", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e3bff07017b8d7860bfb295b4e805f376a9cc6ac --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/instruction.md @@ -0,0 +1,32 @@ +APISpec.to_yaml() method fails with TypeError after recent changes + +#### Description + +The `to_yaml()` method in APISpec is throwing a TypeError when called. It seems like there's an issue with the argument order being passed to the underlying yaml utility function. + +#### Steps/Code to Reproduce + +```python +from apispec import APISpec + +spec = APISpec( + title="Test API", + version="1.0.0", + openapi_version="3.0.0" +) + +# This should work but throws an error +yaml_output = spec.to_yaml() +``` + +#### Error + +``` +TypeError: dict_to_yaml() missing 1 required positional argument: 'data' +``` + +The error suggests that the arguments to `dict_to_yaml()` are being passed in the wrong order or format. Previously this method worked fine for generating YAML output from the spec dictionary. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..aada7f2eac479e789e11aa937adf9731bfbd4867 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "24e2ab1be595b648135a3e70b7b5bc2784273669", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "04112d2ca1b131c061608fbb5c54b8e6189c39da" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_ext_marshmallow_field.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_core.py", + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/core.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 993593, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "58e450f9279684eedad9ec4d60c7843ea4f327a7b998dec18d6f185a07ef320a", + "is_fork": true, + "learner_path": "tasks/b491c0d8099392581ef57f79/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/04112d2ca1b131c061608fbb5c54b8e6189c39da/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9f63a2eaa5b2a77d4e0a4bd4406001c92d391be96abbf626ca370ad0f9e616ed", + "provenance_path": "tasks/b491c0d8099392581ef57f79/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "04112d2ca1b131c061608fbb5c54b8e6189c39da", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "24e2ab1be595b648135a3e70b7b5bc2784273669", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "task_sha256": "8c5ba9cccfd4e92bfe3ba985908417f3b97bd5e79e3b2b9fcd09d924b37c76b4", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..fcee6d7be14cae005c2db952b3561cf021f4b905 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "ec036495f24bdfc187e0075606bb1302ea32f79002282ab5f371e9977f625deb", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/04112d2ca1b131c061608fbb5c54b8e6189c39da/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "2ef340184cc1d9dfcd2cbc9bb05622525f817bc4a8e7dc4790232a42c6108cc0", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "2c968127a5889bc8a89a49adaacdeca97e704272c704ba9868f328aac0ea4bf5", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "58e450f9279684eedad9ec4d60c7843ea4f327a7b998dec18d6f185a07ef320a", + "is_fork": true, + "learner_path": "tasks/b491c0d8099392581ef57f79/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/04112d2ca1b131c061608fbb5c54b8e6189c39da/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9f63a2eaa5b2a77d4e0a4bd4406001c92d391be96abbf626ca370ad0f9e616ed", + "provenance_path": "tasks/b491c0d8099392581ef57f79/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "04112d2ca1b131c061608fbb5c54b8e6189c39da", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "24e2ab1be595b648135a3e70b7b5bc2784273669", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t5dh0iap", + "task_sha256": "8c5ba9cccfd4e92bfe3ba985908417f3b97bd5e79e3b2b9fcd09d924b37c76b4", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..40abbcd98671ccd61c73f35f28c999bb6e2fe599 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/provided-gold.diff @@ -0,0 +1,50 @@ +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c7bdf463986b005f8254bc85691b59c972a45f6c..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -331,9 +331,15 @@ + if "items" in schema: + schema["items"] = self.get_ref("schema", schema["items"]) + self._resolve_refs_in_schema(schema["items"]) ++ for key in ("allOf", "oneOf", "anyOf"): ++ if key in schema: ++ schema[key] = [self.get_ref("schema", s) for s in schema[key]] ++ for sch in schema[key]: ++ self._resolve_refs_in_schema(sch) + if "not" in schema: + schema["not"] = self.get_ref("schema", schema["not"]) + self._resolve_refs_in_schema(schema["not"]) ++ + def _resolve_refs_in_parameter_or_header(self, parameter_or_header) -> None: + self._resolve_schema(parameter_or_header) + self._resolve_examples(parameter_or_header) +@@ -370,12 +376,18 @@ + if "callbacks" in operation: + for callback in operation["callbacks"].values(): + if isinstance(callback, dict): +- pass ++ for path in callback.values(): ++ self.resolve_refs_in_path(path) + if "requestBody" in operation: + self._resolve_refs_in_request_body(operation["requestBody"]) + if "responses" in operation: + responses = {} ++ for code, response in operation["responses"].items(): ++ response = self.get_ref("response", response) ++ self._resolve_refs_in_response(response) ++ responses[code] = response + operation["responses"] = responses ++ + def resolve_refs_in_path(self, path) -> None: + if "parameters" in path: + parameters = [] +@@ -467,8 +479,7 @@ + """ + from .yaml_utils import dict_to_yaml + +- # Swapping the argument order and providing both as positional arguments instead of using a keyword argument. +- return dict_to_yaml(yaml_dump_kwargs, self.to_dict()) ++ return dict_to_yaml(self.to_dict(), yaml_dump_kwargs) + + def tag(self, tag: dict) -> APISpec: + """Store information about a tag. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b4cb288233d7f5065f6d61ff5d3d6adbe3996b5 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/solution/solve.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c7bdf463986b005f8254bc85691b59c972a45f6c..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -331,9 +331,15 @@ + if "items" in schema: + schema["items"] = self.get_ref("schema", schema["items"]) + self._resolve_refs_in_schema(schema["items"]) ++ for key in ("allOf", "oneOf", "anyOf"): ++ if key in schema: ++ schema[key] = [self.get_ref("schema", s) for s in schema[key]] ++ for sch in schema[key]: ++ self._resolve_refs_in_schema(sch) + if "not" in schema: + schema["not"] = self.get_ref("schema", schema["not"]) + self._resolve_refs_in_schema(schema["not"]) ++ + def _resolve_refs_in_parameter_or_header(self, parameter_or_header) -> None: + self._resolve_schema(parameter_or_header) + self._resolve_examples(parameter_or_header) +@@ -370,12 +376,18 @@ + if "callbacks" in operation: + for callback in operation["callbacks"].values(): + if isinstance(callback, dict): +- pass ++ for path in callback.values(): ++ self.resolve_refs_in_path(path) + if "requestBody" in operation: + self._resolve_refs_in_request_body(operation["requestBody"]) + if "responses" in operation: + responses = {} ++ for code, response in operation["responses"].items(): ++ response = self.get_ref("response", response) ++ self._resolve_refs_in_response(response) ++ responses[code] = response + operation["responses"] = responses ++ + def resolve_refs_in_path(self, path) -> None: + if "parameters" in path: + parameters = [] +@@ -467,8 +479,7 @@ + """ + from .yaml_utils import dict_to_yaml + +- # Swapping the argument order and providing both as positional arguments instead of using a keyword argument. +- return dict_to_yaml(yaml_dump_kwargs, self.to_dict()) ++ return dict_to_yaml(self.to_dict(), yaml_dump_kwargs) + + def tag(self, tag: dict) -> APISpec: + """Store information about a tag. +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..2e325ec927e1bdb3517e1d3c72ef740ec0a8a270 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:764c60a55750844cbf153977b51a42456df522f4355353cafb526be09d5ae9f0" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..a40532b6f76149c0638b2320948ac175bb82b4bf --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..84b9505ebd4deeb02d1ec770f56497f52696c76b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/first-hunk-only.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c7bdf463986b005f8254bc85691b59c972a45f6c..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -331,9 +331,15 @@ + if "items" in schema: + schema["items"] = self.get_ref("schema", schema["items"]) + self._resolve_refs_in_schema(schema["items"]) ++ for key in ("allOf", "oneOf", "anyOf"): ++ if key in schema: ++ schema[key] = [self.get_ref("schema", s) for s in schema[key]] ++ for sch in schema[key]: ++ self._resolve_refs_in_schema(sch) + if "not" in schema: + schema["not"] = self.get_ref("schema", schema["not"]) + self._resolve_refs_in_schema(schema["not"]) ++ + def _resolve_refs_in_parameter_or_header(self, parameter_or_header) -> None: + self._resolve_schema(parameter_or_header) + self._resolve_examples(parameter_or_header) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t5dh0iap/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..3b836ecc453157d5ee85820f37aebf98de86e689 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "b1165fc41b3268beff5146bdbf347d3edc2bcbf981cc428ab7765bf6288a3b1d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "7395960de95f9713ac20ad8f9a8a521dd7d3cef14f3c226fc92aee8438eca08d", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "e69afe22aa4939c720541e71773f630465505b70529963ab90f14a5a92901af8", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75", + "source_completion_sha256": "8d4dc07504889fb1bb7df58c566fa9a9a08a7eb56750f6d1d15dc1c29fa71855", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "101691548da9da6213c60f0b8fd5410a6fcac57ce8fb9e458fe1040517d9d712", + "is_fork": true, + "learner_path": "tasks/c2bf65562dfab8622470b5a6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "bd2851f74bf02e76263c5685bbd3fed18bad4a0dfa107cf860a9ec8ef827b6e2", + "provenance_path": "tasks/c2bf65562dfab8622470b5a6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "e8e76aa4dddfc996897f387813d76b90a3242da6", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "task_sha256": "7f4bca77ef14877146a45f6faba5239472e113271c5a5d7d9d3b9f2c382dfe65", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0b216c335b13914cc14963e4ed26a3713656b80a --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/instruction.md @@ -0,0 +1,43 @@ +Schema resolver breaks with array items processing + +#### Description + +When using array schemas with nested items, the schema resolver fails to properly process the `items` field. Instead of resolving the nested schema in the `items` property, it creates a `not_items` property and leaves the original `items` unresolved. + +#### Steps/Code to Reproduce + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +from marshmallow import Schema, fields + +class PetSchema(Schema): + name = fields.Str() + id = fields.Int() + +spec = APISpec( + title="Test API", + version="1.0.0", + openapi_version="3.0.0", + plugins=[MarshmallowPlugin()] +) + +# Register the schema +spec.components.schema("Pet", schema=PetSchema) + +# Try to use an array schema with items +array_schema = { + "type": "array", + "items": PetSchema +} + +# This should resolve the items to a reference, but creates not_items instead +resolved = spec.plugins[0].resolver.resolve_schema_dict(array_schema) +print("Expected items to be resolved to $ref, but got:", resolved) +``` + +The expected output should have `items` containing a proper schema reference, but instead the resolver creates a `not_items` field and leaves `items` unprocessed. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..c5badd5ed241efafe967b15fca31b9d7dbacf7f0 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "e8e76aa4dddfc996897f387813d76b90a3242da6", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_ext_marshmallow_field.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/schema_resolver.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1043573, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "101691548da9da6213c60f0b8fd5410a6fcac57ce8fb9e458fe1040517d9d712", + "is_fork": true, + "learner_path": "tasks/c2bf65562dfab8622470b5a6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "bd2851f74bf02e76263c5685bbd3fed18bad4a0dfa107cf860a9ec8ef827b6e2", + "provenance_path": "tasks/c2bf65562dfab8622470b5a6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "e8e76aa4dddfc996897f387813d76b90a3242da6", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "task_sha256": "7f4bca77ef14877146a45f6faba5239472e113271c5a5d7d9d3b9f2c382dfe65", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..9099dfa4dafe4d75632b4ca9b199ad221a324ec5 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "b1165fc41b3268beff5146bdbf347d3edc2bcbf981cc428ab7765bf6288a3b1d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "8d4dc07504889fb1bb7df58c566fa9a9a08a7eb56750f6d1d15dc1c29fa71855", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "b5de6e0a40d8d41806585b1a47fc91b6793a8f96b4dff2f5e8292394f7f70068", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "101691548da9da6213c60f0b8fd5410a6fcac57ce8fb9e458fe1040517d9d712", + "is_fork": true, + "learner_path": "tasks/c2bf65562dfab8622470b5a6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "bd2851f74bf02e76263c5685bbd3fed18bad4a0dfa107cf860a9ec8ef827b6e2", + "provenance_path": "tasks/c2bf65562dfab8622470b5a6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f53e6fa3b3c4c1d2420d40b616e9c3374fa41b75", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "e8e76aa4dddfc996897f387813d76b90a3242da6", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t898ju4l", + "task_sha256": "7f4bca77ef14877146a45f6faba5239472e113271c5a5d7d9d3b9f2c382dfe65", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..04540e91a44e73b6df31bb1789e677b86b7bc355 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/provided-gold.diff @@ -0,0 +1,93 @@ +diff --git a/src/apispec/ext/marshmallow/schema_resolver.py b/src/apispec/ext/marshmallow/schema_resolver.py +index ff819371da96c581f5ab8ffd0693e3fc1dc2e6b6..355d886068bbcc4dbeb5bb7bf5cad2202810bdd4 100644 +--- a/src/apispec/ext/marshmallow/schema_resolver.py ++++ b/src/apispec/ext/marshmallow/schema_resolver.py +@@ -12,8 +12,8 @@ + """ + + def __init__(self, openapi_version, converter): +- self.openapi_version = converter +- self.converter = openapi_version ++ self.openapi_version = openapi_version ++ self.converter = converter + + def resolve_operations(self, operations, **kwargs): + """Resolve marshmallow Schemas in a dict mapping operation to OpenApi `Operation Object +@@ -74,11 +74,10 @@ + + + """ +- for callback in list(callbacks.values())[::-1]: # Change iteration order +- if not isinstance(callback, dict): # Add incorrect condition check +- continue # Skip processing for valid dicts +- for path in callback.keys(): # Iterate incorrectly over keys instead of values +- self.resolve_operations(callback) ++ for callback in callbacks.values(): ++ if isinstance(callback, dict): ++ for path in callback.values(): ++ self.resolve_operations(path) + + def resolve_parameters(self, parameters): + """Resolve marshmallow Schemas in a list of OpenAPI `Parameter Objects +@@ -231,15 +230,58 @@ + content["schema"] = self.resolve_schema_dict(content["schema"]) + + def resolve_schema_dict(self, schema): ++ """Resolve a marshmallow Schema class, object, or a string that resolves ++ to a Schema class or a schema reference or an OpenAPI Schema Object ++ containing one of the above to an OpenAPI Schema Object or Reference Object. ++ ++ If the input is a marshmallow Schema class, object or a string that resolves ++ to a Schema class the Schema will be translated to an OpenAPI Schema Object ++ or Reference Object. ++ ++ Example: :: ++ ++ # Input ++ "PetSchema" ++ ++ # Output ++ {"$ref": "#/components/schemas/Pet"} ++ ++ If the input is a dictionary representation of an OpenAPI Schema Object ++ recursively search for a marshmallow Schemas to resolve. For `"type": "array"`, ++ marshmallow Schemas may appear as the value of the `items` key. For ++ `"type": "object"` Marshmalow Schemas may appear as values in the `properties` ++ dictionary. ++ ++ Examples: :: ++ ++ # Input ++ {"type": "array", "items": "PetSchema"} ++ ++ # Output ++ {"type": "array", "items": {"$ref": "#/components/schemas/Pet"}} ++ ++ # Input ++ {"type": "object", "properties": {"pet": "PetSchcema", "user": "UserSchema"}} ++ ++ # Output ++ { ++ "type": "object", ++ "properties": { ++ "pet": {"$ref": "#/components/schemas/Pet"}, ++ "user": {"$ref": "#/components/schemas/User"}, ++ }, ++ } ++ ++ :param string|Schema|dict schema: the schema to resolve. ++ """ + if isinstance(schema, dict): ++ if schema.get("type") == "array" and "items" in schema: ++ schema["items"] = self.resolve_schema_dict(schema["items"]) + if schema.get("type") == "object" and "properties" in schema: + schema["properties"] = { + k: self.resolve_schema_dict(v) + for k, v in schema["properties"].items() + } +- if schema.get("type") == "array" and "items" in schema: +- if isinstance(schema["items"], dict): +- schema["not_items"] = self.resolve_schema_dict(schema["items"]) + for keyword in ("oneOf", "anyOf", "allOf"): + if keyword in schema: + schema[keyword] = [ diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..87d80d6b39902bf2911e2f56ab1e6809127e418c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/solution/solve.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/schema_resolver.py b/src/apispec/ext/marshmallow/schema_resolver.py +index ff819371da96c581f5ab8ffd0693e3fc1dc2e6b6..355d886068bbcc4dbeb5bb7bf5cad2202810bdd4 100644 +--- a/src/apispec/ext/marshmallow/schema_resolver.py ++++ b/src/apispec/ext/marshmallow/schema_resolver.py +@@ -12,8 +12,8 @@ + """ + + def __init__(self, openapi_version, converter): +- self.openapi_version = converter +- self.converter = openapi_version ++ self.openapi_version = openapi_version ++ self.converter = converter + + def resolve_operations(self, operations, **kwargs): + """Resolve marshmallow Schemas in a dict mapping operation to OpenApi `Operation Object +@@ -74,11 +74,10 @@ + + + """ +- for callback in list(callbacks.values())[::-1]: # Change iteration order +- if not isinstance(callback, dict): # Add incorrect condition check +- continue # Skip processing for valid dicts +- for path in callback.keys(): # Iterate incorrectly over keys instead of values +- self.resolve_operations(callback) ++ for callback in callbacks.values(): ++ if isinstance(callback, dict): ++ for path in callback.values(): ++ self.resolve_operations(path) + + def resolve_parameters(self, parameters): + """Resolve marshmallow Schemas in a list of OpenAPI `Parameter Objects +@@ -231,15 +230,58 @@ + content["schema"] = self.resolve_schema_dict(content["schema"]) + + def resolve_schema_dict(self, schema): ++ """Resolve a marshmallow Schema class, object, or a string that resolves ++ to a Schema class or a schema reference or an OpenAPI Schema Object ++ containing one of the above to an OpenAPI Schema Object or Reference Object. ++ ++ If the input is a marshmallow Schema class, object or a string that resolves ++ to a Schema class the Schema will be translated to an OpenAPI Schema Object ++ or Reference Object. ++ ++ Example: :: ++ ++ # Input ++ "PetSchema" ++ ++ # Output ++ {"$ref": "#/components/schemas/Pet"} ++ ++ If the input is a dictionary representation of an OpenAPI Schema Object ++ recursively search for a marshmallow Schemas to resolve. For `"type": "array"`, ++ marshmallow Schemas may appear as the value of the `items` key. For ++ `"type": "object"` Marshmalow Schemas may appear as values in the `properties` ++ dictionary. ++ ++ Examples: :: ++ ++ # Input ++ {"type": "array", "items": "PetSchema"} ++ ++ # Output ++ {"type": "array", "items": {"$ref": "#/components/schemas/Pet"}} ++ ++ # Input ++ {"type": "object", "properties": {"pet": "PetSchcema", "user": "UserSchema"}} ++ ++ # Output ++ { ++ "type": "object", ++ "properties": { ++ "pet": {"$ref": "#/components/schemas/Pet"}, ++ "user": {"$ref": "#/components/schemas/User"}, ++ }, ++ } ++ ++ :param string|Schema|dict schema: the schema to resolve. ++ """ + if isinstance(schema, dict): ++ if schema.get("type") == "array" and "items" in schema: ++ schema["items"] = self.resolve_schema_dict(schema["items"]) + if schema.get("type") == "object" and "properties" in schema: + schema["properties"] = { + k: self.resolve_schema_dict(v) + for k, v in schema["properties"].items() + } +- if schema.get("type") == "array" and "items" in schema: +- if isinstance(schema["items"], dict): +- schema["not_items"] = self.resolve_schema_dict(schema["items"]) + for keyword in ("oneOf", "anyOf", "allOf"): + if keyword in schema: + schema[keyword] = [ +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cfac3215becac24f7fa869a335f9c4e47cdbd323 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:f484cca239427b2a6c661072caabd926762069bc880b9655a0e56f304d2727a3" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..4a3896c1a05268daaca1dacf5d2172f5011ce382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ab332b21289ddcf246f61815c7460c8b268d7ce --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/first-hunk-only.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/schema_resolver.py b/src/apispec/ext/marshmallow/schema_resolver.py +index ff819371da96c581f5ab8ffd0693e3fc1dc2e6b6..355d886068bbcc4dbeb5bb7bf5cad2202810bdd4 100644 +--- a/src/apispec/ext/marshmallow/schema_resolver.py ++++ b/src/apispec/ext/marshmallow/schema_resolver.py +@@ -12,8 +12,8 @@ + """ + + def __init__(self, openapi_version, converter): +- self.openapi_version = converter +- self.converter = openapi_version ++ self.openapi_version = openapi_version ++ self.converter = converter + + def resolve_operations(self, operations, **kwargs): + """Resolve marshmallow Schemas in a dict mapping operation to OpenApi `Operation Object +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t898ju4l/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..fae091c11b1a73ca4d5670741920eaddd099a36a --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "b6dac46640e8203808dfcaa3e6aeef5271c4d1422dfc735f8a0e5f353e73845d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "658bcc2747e7cb1ece5bb884fb1a35b4f001f2dfc0fd54a0104fa70435bb23f7", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "47e4b73251cef1424cfc1735b03c5de5309b4a237856dbfc51ecc4d14d354a27", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "3df0f55730dfb46ab08eef8b66b0dc696e1f46de", + "source_completion_sha256": "87b8effcf4c4399ff9f9739dab1739fa01775d2dc22291b6b60d5df9ca656a76", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "aa9ed98f90bc0b12c4af37166a8b55221b6c1bd11f53e340199b241c029f049a", + "is_fork": true, + "learner_path": "tasks/752c54c84f27d8ee565c3e96/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/3df0f55730dfb46ab08eef8b66b0dc696e1f46de/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e07c9c6ea69b7df9383482d195d4ede2a96b759167eae663b2de489f84a2811a", + "provenance_path": "tasks/752c54c84f27d8ee565c3e96/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3df0f55730dfb46ab08eef8b66b0dc696e1f46de", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "002628efeae052c9bfe0cb48d29a1a0d6480d30f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "task_sha256": "0bacc9b982b0b4877c422c04624e13302f21b01aac354395f32b8a8e566e9462", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..f5e8ef2142bf67c942333bde490bfb59fbb2fe50 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/instruction.md @@ -0,0 +1,56 @@ +# Multiple critical bugs in APISpec component handling + +I've discovered several critical issues in the APISpec component handling that break core functionality. Here's what I found: + +## Schema component issues +- The `schema` method in `Components` class is not returning `self`, making it impossible to chain method calls +- The method is using `kwargs` instead of `component` for the deepcopy operation +- Plugin helpers are being called in reverse order, which changes the expected behavior +- Plugin helpers are not receiving the `kwargs` parameter + +## Parameter component issues +- The `parameter` method has an inverted condition for duplicate name checking +- The method is swapping `component_id` and `location` values in the parameter definition +- Path parameters are incorrectly marked as not required (should be required) +- The `ret` dictionary is being unexpectedly cleared during plugin helper processing +- The method is registering components with incorrect names and lazy settings + +## Reference resolution issues +- The `_resolve_refs_in_schema` method has incorrect ordering of operations for items, causing references to not be properly resolved +- There's an off-by-one error in the loop that processes schema lists (allOf, oneOf, anyOf) +- The "not" schema reference resolution is performed in the wrong order + +## YAML output issue +- The `to_yaml` method is incorrectly passing arguments to `dict_to_yaml` + +## Reproduction + +Here's a simple example that demonstrates one of the issues: + +```python +from apispec import APISpec + +spec = APISpec( + title="Test API", + version="1.0.0", + openapi_version="3.0.0" +) + +# This should be chainable but fails +try: + spec.components.schema("Pet", {"type": "object"}).schema("Error", {"type": "object"}) + print("Chaining works") +except AttributeError: + print("Chaining fails - schema() doesn't return self") + +# Parameter definition is broken +spec.components.parameter("pet_id", "path", {"type": "integer"}) +print(spec.to_dict()) +# Shows incorrect parameter definition with swapped values +``` + +The issues affect core functionality like schema definition, parameter handling, and reference resolution, making the library unusable for many common use cases. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..ddad39c27a5cfdba9d135ec3d82fb4371f59793f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "002628efeae052c9bfe0cb48d29a1a0d6480d30f", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "3df0f55730dfb46ab08eef8b66b0dc696e1f46de" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_core.py", + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_common.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/core.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 969823, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "aa9ed98f90bc0b12c4af37166a8b55221b6c1bd11f53e340199b241c029f049a", + "is_fork": true, + "learner_path": "tasks/752c54c84f27d8ee565c3e96/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/3df0f55730dfb46ab08eef8b66b0dc696e1f46de/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e07c9c6ea69b7df9383482d195d4ede2a96b759167eae663b2de489f84a2811a", + "provenance_path": "tasks/752c54c84f27d8ee565c3e96/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3df0f55730dfb46ab08eef8b66b0dc696e1f46de", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "002628efeae052c9bfe0cb48d29a1a0d6480d30f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "task_sha256": "0bacc9b982b0b4877c422c04624e13302f21b01aac354395f32b8a8e566e9462", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..4fe16f3529e9abbfc20b9f8755f992cc7b3427e7 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "b6dac46640e8203808dfcaa3e6aeef5271c4d1422dfc735f8a0e5f353e73845d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/3df0f55730dfb46ab08eef8b66b0dc696e1f46de/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "87b8effcf4c4399ff9f9739dab1739fa01775d2dc22291b6b60d5df9ca656a76", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "df67c5da56629164baa6d5786d311d5aab43be3b5c37fd30044b3714975642bf", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "aa9ed98f90bc0b12c4af37166a8b55221b6c1bd11f53e340199b241c029f049a", + "is_fork": true, + "learner_path": "tasks/752c54c84f27d8ee565c3e96/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/3df0f55730dfb46ab08eef8b66b0dc696e1f46de/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e07c9c6ea69b7df9383482d195d4ede2a96b759167eae663b2de489f84a2811a", + "provenance_path": "tasks/752c54c84f27d8ee565c3e96/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3df0f55730dfb46ab08eef8b66b0dc696e1f46de", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "002628efeae052c9bfe0cb48d29a1a0d6480d30f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__t9uhnzom", + "task_sha256": "0bacc9b982b0b4877c422c04624e13302f21b01aac354395f32b8a8e566e9462", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..58316899eb585e4b891b6530d49f20bb1e9237fb --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/provided-gold.diff @@ -0,0 +1,103 @@ +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c8268ca1a9a8324a2edddf58e1d061f6544b0354..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -164,16 +164,16 @@ + raise DuplicateComponentNameError( + f'Another schema with name "{component_id}" is already registered.' + ) +- ret = deepcopy(kwargs) or {} ++ ret = deepcopy(component) or {} + # Execute all helpers from plugins +- for plugin in reversed(self._plugins): ++ for plugin in self._plugins: + try: +- ret.update(plugin.schema_helper(component_id, ret) or {}) ++ ret.update(plugin.schema_helper(component_id, ret, **kwargs) or {}) + except PluginMethodNotImplementedError: + continue + self._resolve_refs_in_schema(ret) +- self._register_component("schema", component_id, ret, lazy=not lazy) +- return None ++ self._register_component("schema", component_id, ret, lazy=lazy) ++ return self + + def response( + self, +@@ -222,28 +222,27 @@ + :param bool lazy: register component only when referenced in the spec + :param kwargs: plugin-specific arguments + """ +- if component_id not in self.parameters: ++ if component_id in self.parameters: + raise DuplicateComponentNameError( + f'Another parameter with name "{component_id}" is already registered.' + ) + ret = deepcopy(component) or {} +- ret.setdefault("name", location) +- ret["in"] = component_id ++ ret.setdefault("name", component_id) ++ ret["in"] = location + + # if "in" is set to "path", enforce required flag to True + if location == "path": +- ret["required"] = False ++ ret["required"] = True + + # Execute all helpers from plugins + for plugin in self._plugins: + try: +- ret.clear() # Unexpectedly clearing the dictionary + ret.update(plugin.parameter_helper(ret, **kwargs) or {}) + except PluginMethodNotImplementedError: + continue + self._resolve_refs_in_parameter_or_header(ret) +- self._register_component("parameter", location, ret, lazy=not lazy) +- return None ++ self._register_component("parameter", component_id, ret, lazy=lazy) ++ return self + + def header( + self, +@@ -324,26 +323,22 @@ + + def _resolve_refs_in_schema(self, schema: dict) -> None: + if "properties" in schema: +- for key in list(schema["properties"]): ++ for key in schema["properties"]: + schema["properties"][key] = self.get_ref( + "schema", schema["properties"][key] + ) +- # Reverse the call to resolve the reference before updating it + self._resolve_refs_in_schema(schema["properties"][key]) + if "items" in schema: +- # Incorrectly update the 'items' without resolving its references first ++ schema["items"] = self.get_ref("schema", schema["items"]) + self._resolve_refs_in_schema(schema["items"]) +- schema["items"] = self.get_ref("schema", schema["items"]) + for key in ("allOf", "oneOf", "anyOf"): + if key in schema: + schema[key] = [self.get_ref("schema", s) for s in schema[key]] +- # Use an off-by-one error in the loop +- for i, sch in enumerate(schema[key][:-1]): +- self._resolve_refs_in_schema(schema[key][i]) ++ for sch in schema[key]: ++ self._resolve_refs_in_schema(sch) + if "not" in schema: ++ schema["not"] = self.get_ref("schema", schema["not"]) + self._resolve_refs_in_schema(schema["not"]) +- # Incorrectly apply get_ref after recursive call +- schema["not"] = self.get_ref("schema", schema["not"]) + + def _resolve_refs_in_parameter_or_header(self, parameter_or_header) -> None: + self._resolve_schema(parameter_or_header) +@@ -484,8 +479,7 @@ + """ + from .yaml_utils import dict_to_yaml + +- # Swapping the argument order and providing both as positional arguments instead of using a keyword argument. +- return dict_to_yaml(yaml_dump_kwargs, self.to_dict()) ++ return dict_to_yaml(self.to_dict(), yaml_dump_kwargs) + + def tag(self, tag: dict) -> APISpec: + """Store information about a tag. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb47ce786916050cf76205ea8e94fc5c5a5850b1 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/solution/solve.sh @@ -0,0 +1,109 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c8268ca1a9a8324a2edddf58e1d061f6544b0354..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -164,16 +164,16 @@ + raise DuplicateComponentNameError( + f'Another schema with name "{component_id}" is already registered.' + ) +- ret = deepcopy(kwargs) or {} ++ ret = deepcopy(component) or {} + # Execute all helpers from plugins +- for plugin in reversed(self._plugins): ++ for plugin in self._plugins: + try: +- ret.update(plugin.schema_helper(component_id, ret) or {}) ++ ret.update(plugin.schema_helper(component_id, ret, **kwargs) or {}) + except PluginMethodNotImplementedError: + continue + self._resolve_refs_in_schema(ret) +- self._register_component("schema", component_id, ret, lazy=not lazy) +- return None ++ self._register_component("schema", component_id, ret, lazy=lazy) ++ return self + + def response( + self, +@@ -222,28 +222,27 @@ + :param bool lazy: register component only when referenced in the spec + :param kwargs: plugin-specific arguments + """ +- if component_id not in self.parameters: ++ if component_id in self.parameters: + raise DuplicateComponentNameError( + f'Another parameter with name "{component_id}" is already registered.' + ) + ret = deepcopy(component) or {} +- ret.setdefault("name", location) +- ret["in"] = component_id ++ ret.setdefault("name", component_id) ++ ret["in"] = location + + # if "in" is set to "path", enforce required flag to True + if location == "path": +- ret["required"] = False ++ ret["required"] = True + + # Execute all helpers from plugins + for plugin in self._plugins: + try: +- ret.clear() # Unexpectedly clearing the dictionary + ret.update(plugin.parameter_helper(ret, **kwargs) or {}) + except PluginMethodNotImplementedError: + continue + self._resolve_refs_in_parameter_or_header(ret) +- self._register_component("parameter", location, ret, lazy=not lazy) +- return None ++ self._register_component("parameter", component_id, ret, lazy=lazy) ++ return self + + def header( + self, +@@ -324,26 +323,22 @@ + + def _resolve_refs_in_schema(self, schema: dict) -> None: + if "properties" in schema: +- for key in list(schema["properties"]): ++ for key in schema["properties"]: + schema["properties"][key] = self.get_ref( + "schema", schema["properties"][key] + ) +- # Reverse the call to resolve the reference before updating it + self._resolve_refs_in_schema(schema["properties"][key]) + if "items" in schema: +- # Incorrectly update the 'items' without resolving its references first ++ schema["items"] = self.get_ref("schema", schema["items"]) + self._resolve_refs_in_schema(schema["items"]) +- schema["items"] = self.get_ref("schema", schema["items"]) + for key in ("allOf", "oneOf", "anyOf"): + if key in schema: + schema[key] = [self.get_ref("schema", s) for s in schema[key]] +- # Use an off-by-one error in the loop +- for i, sch in enumerate(schema[key][:-1]): +- self._resolve_refs_in_schema(schema[key][i]) ++ for sch in schema[key]: ++ self._resolve_refs_in_schema(sch) + if "not" in schema: ++ schema["not"] = self.get_ref("schema", schema["not"]) + self._resolve_refs_in_schema(schema["not"]) +- # Incorrectly apply get_ref after recursive call +- schema["not"] = self.get_ref("schema", schema["not"]) + + def _resolve_refs_in_parameter_or_header(self, parameter_or_header) -> None: + self._resolve_schema(parameter_or_header) +@@ -484,8 +479,7 @@ + """ + from .yaml_utils import dict_to_yaml + +- # Swapping the argument order and providing both as positional arguments instead of using a keyword argument. +- return dict_to_yaml(yaml_dump_kwargs, self.to_dict()) ++ return dict_to_yaml(self.to_dict(), yaml_dump_kwargs) + + def tag(self, tag: dict) -> APISpec: + """Store information about a tag. +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..cba0047a6cd17bd8daae11ab25e6ab7dab6929ed --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:70e42da9a8e16825b65a23b14dfb103c3aa090d5c7ef43773653c246288a5093" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..da4c0af835326bc4f04f38824e6b8be0d37ed97b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..6015365fcf9042aa2cee5c263dac27e4dece50bb --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/first-hunk-only.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/core.py b/src/apispec/core.py +index c8268ca1a9a8324a2edddf58e1d061f6544b0354..e9ccb40635faff1ceb3d7234d7458cb6db4ae67d 100644 +--- a/src/apispec/core.py ++++ b/src/apispec/core.py +@@ -164,16 +164,16 @@ + raise DuplicateComponentNameError( + f'Another schema with name "{component_id}" is already registered.' + ) +- ret = deepcopy(kwargs) or {} ++ ret = deepcopy(component) or {} + # Execute all helpers from plugins +- for plugin in reversed(self._plugins): ++ for plugin in self._plugins: + try: +- ret.update(plugin.schema_helper(component_id, ret) or {}) ++ ret.update(plugin.schema_helper(component_id, ret, **kwargs) or {}) + except PluginMethodNotImplementedError: + continue + self._resolve_refs_in_schema(ret) +- self._register_component("schema", component_id, ret, lazy=not lazy) +- return None ++ self._register_component("schema", component_id, ret, lazy=lazy) ++ return self + + def response( + self, +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__t9uhnzom/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..900dac23fc531a7754f6f87a786b474574c7e272 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "9141ab5a4e87a8fa7d9de429705f7d9015150891f81c814a5237f66d6cd89b8c", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "f562ee093d7f921b236072159e0a319545f09005b69a6aaed1db1bae6793799d", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "f6600fe0b51f69a2ec862d40332ad3c6e852683222f18274418b0e4834ad09a0", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "15a17e1233ab7377f3c505a747bd381088392092", + "source_completion_sha256": "4b1d36857260f13117fbfd15eedd0609a86a12fb40e05b808b1418f52a29a371", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "c688a8ac319a53bfed746d42207aa493d92d15eea0873f5e7e8aa0f884623f45", + "is_fork": true, + "learner_path": "tasks/451fd2a9d79d9a5d50f7781e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/15a17e1233ab7377f3c505a747bd381088392092/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9064fd75e8e8c45cfd589f9d6ebedb6003c7345d45fcd4b57098a9b11b4079da", + "provenance_path": "tasks/451fd2a9d79d9a5d50f7781e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "15a17e1233ab7377f3c505a747bd381088392092", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "c34a913f120f1d859a8aaa17fb6e2770eb96423b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "task_sha256": "67f7e969fab53f9f664930ba958d671e94cdc3532bac7344b454e981890d82fa", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cb1a5ee68d6d71d21a849a729129a99b9a3ca1b9 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/instruction.md @@ -0,0 +1,40 @@ +Schema conversion returns incorrect structure after RegistryError + +#### Description + +When converting schemas with the Marshmallow extension, if a RegistryError occurs during schema resolution, the converter now returns an unexpected structure instead of the original schema string reference. + +#### Steps/Code to Reproduce + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +import marshmallow + +# Create a spec with marshmallow plugin +spec = APISpec( + title='Test API', + version='1.0.0', + openapi_version='3.0.0', + plugins=[MarshmallowPlugin()] +) + +# Try to reference a schema that doesn't exist in registry +# This should return the original string reference but now returns something else +try: + result = spec.plugins[0].converter.resolve_schema('NonExistentSchema') + print(f"Got: {result}") + print(f"Expected: 'NonExistentSchema'") +except Exception as e: + print(f"Error: {e}") +``` + +The converter should return the original schema string when a RegistryError occurs, but it's now returning a different structure that breaks schema references. + +#### Additional Context + +This affects schema resolution when referencing schemas that aren't registered yet, which is a common pattern when building API specifications incrementally. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..f10b808e77a5ed24f143c3275f4f1828065fba1a --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "c34a913f120f1d859a8aaa17fb6e2770eb96423b", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "15a17e1233ab7377f3c505a747bd381088392092" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/openapi.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1024339, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "c688a8ac319a53bfed746d42207aa493d92d15eea0873f5e7e8aa0f884623f45", + "is_fork": true, + "learner_path": "tasks/451fd2a9d79d9a5d50f7781e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/15a17e1233ab7377f3c505a747bd381088392092/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9064fd75e8e8c45cfd589f9d6ebedb6003c7345d45fcd4b57098a9b11b4079da", + "provenance_path": "tasks/451fd2a9d79d9a5d50f7781e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "15a17e1233ab7377f3c505a747bd381088392092", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "c34a913f120f1d859a8aaa17fb6e2770eb96423b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "task_sha256": "67f7e969fab53f9f664930ba958d671e94cdc3532bac7344b454e981890d82fa", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8dd2a103f1f67ef27caecc6a46cecf7bc1e8106 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "9141ab5a4e87a8fa7d9de429705f7d9015150891f81c814a5237f66d6cd89b8c", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/15a17e1233ab7377f3c505a747bd381088392092/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "4b1d36857260f13117fbfd15eedd0609a86a12fb40e05b808b1418f52a29a371", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "1784d86c2475ee9cced6397887c8f212e32587dfaec2e88bbecc44e5fdce5a92", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "c688a8ac319a53bfed746d42207aa493d92d15eea0873f5e7e8aa0f884623f45", + "is_fork": true, + "learner_path": "tasks/451fd2a9d79d9a5d50f7781e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/15a17e1233ab7377f3c505a747bd381088392092/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "9064fd75e8e8c45cfd589f9d6ebedb6003c7345d45fcd4b57098a9b11b4079da", + "provenance_path": "tasks/451fd2a9d79d9a5d50f7781e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "15a17e1233ab7377f3c505a747bd381088392092", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "c34a913f120f1d859a8aaa17fb6e2770eb96423b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ukmznjln", + "task_sha256": "67f7e969fab53f9f664930ba958d671e94cdc3532bac7344b454e981890d82fa", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..fc90b3c9fddbf26bc465d2e788adeb7bcf4162a6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/provided-gold.diff @@ -0,0 +1,62 @@ +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index de7fbd2ad2f56c1fad264b4970bbffa404172d2b..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -110,8 +110,10 @@ + """ + try: + schema_instance = resolve_schema_instance(schema) ++ # If schema is a string and is not found in registry, ++ # assume it is a schema reference + except marshmallow.exceptions.RegistryError: +- return self.get_ref_dict(schema) # Changed output in case of RegistryError ++ return schema + schema_key = make_schema_key(schema_instance) + if schema_key not in self.refs: + name = self.schema_name_resolver(schema) +@@ -126,12 +128,12 @@ + " MarshmallowPlugin returns a string for all circular" + " referencing schemas." + ) from exc +- if getattr(schema, "many", True): # Changed False to True here ++ if getattr(schema, "many", False): + return {"type": "array", "items": json_schema} + return json_schema +- self.spec.components.schema(name, schema=schema_instance) # Changed schema to schema_instance +- name = get_unique_schema_name(self.spec.components, name) # Swapped order with the previous line +- return schema_instance # Changed self.get_ref_dict(schema_instance) to schema_instance ++ name = get_unique_schema_name(self.spec.components, name) ++ self.spec.components.schema(name, schema=schema) ++ return self.get_ref_dict(schema_instance) + + def schema2parameters( + self, +@@ -215,8 +217,8 @@ + """ + ret = {} + partial = getattr(field.parent, "partial", False) +- ret["required"] = not field.required or ( +- partial and (not is_collection(partial) or field.name in partial) # type:ignore ++ ret["required"] = field.required and ( ++ not partial or (is_collection(partial) and field.name not in partial) # type:ignore + ) + return ret + +@@ -250,13 +252,13 @@ + Meta = getattr(schema, "Meta", None) + partial = getattr(schema, "partial", None) + +- jsonschema = self.fields2jsonschema(fields, partial=not partial) # Bug: Inverted partial logic ++ jsonschema = self.fields2jsonschema(fields, partial=partial) + + if hasattr(Meta, "title"): +- jsonschema["description"] = Meta.title # Bug: Swapped title and description ++ jsonschema["title"] = Meta.title + if hasattr(Meta, "description"): +- jsonschema["title"] = Meta.description # Bug: Swapped title and description +- if hasattr(Meta, "unknown") and Meta.unknown == marshmallow.EXCLUDE: # Bug: Incorrect comparison logic ++ jsonschema["description"] = Meta.description ++ if hasattr(Meta, "unknown") and Meta.unknown != marshmallow.EXCLUDE: + jsonschema["additionalProperties"] = Meta.unknown == marshmallow.INCLUDE + + return jsonschema diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..36e70ef3dce8c2e16ed43336b0293314ae77ebca --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/solution/solve.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index de7fbd2ad2f56c1fad264b4970bbffa404172d2b..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -110,8 +110,10 @@ + """ + try: + schema_instance = resolve_schema_instance(schema) ++ # If schema is a string and is not found in registry, ++ # assume it is a schema reference + except marshmallow.exceptions.RegistryError: +- return self.get_ref_dict(schema) # Changed output in case of RegistryError ++ return schema + schema_key = make_schema_key(schema_instance) + if schema_key not in self.refs: + name = self.schema_name_resolver(schema) +@@ -126,12 +128,12 @@ + " MarshmallowPlugin returns a string for all circular" + " referencing schemas." + ) from exc +- if getattr(schema, "many", True): # Changed False to True here ++ if getattr(schema, "many", False): + return {"type": "array", "items": json_schema} + return json_schema +- self.spec.components.schema(name, schema=schema_instance) # Changed schema to schema_instance +- name = get_unique_schema_name(self.spec.components, name) # Swapped order with the previous line +- return schema_instance # Changed self.get_ref_dict(schema_instance) to schema_instance ++ name = get_unique_schema_name(self.spec.components, name) ++ self.spec.components.schema(name, schema=schema) ++ return self.get_ref_dict(schema_instance) + + def schema2parameters( + self, +@@ -215,8 +217,8 @@ + """ + ret = {} + partial = getattr(field.parent, "partial", False) +- ret["required"] = not field.required or ( +- partial and (not is_collection(partial) or field.name in partial) # type:ignore ++ ret["required"] = field.required and ( ++ not partial or (is_collection(partial) and field.name not in partial) # type:ignore + ) + return ret + +@@ -250,13 +252,13 @@ + Meta = getattr(schema, "Meta", None) + partial = getattr(schema, "partial", None) + +- jsonschema = self.fields2jsonschema(fields, partial=not partial) # Bug: Inverted partial logic ++ jsonschema = self.fields2jsonschema(fields, partial=partial) + + if hasattr(Meta, "title"): +- jsonschema["description"] = Meta.title # Bug: Swapped title and description ++ jsonschema["title"] = Meta.title + if hasattr(Meta, "description"): +- jsonschema["title"] = Meta.description # Bug: Swapped title and description +- if hasattr(Meta, "unknown") and Meta.unknown == marshmallow.EXCLUDE: # Bug: Incorrect comparison logic ++ jsonschema["description"] = Meta.description ++ if hasattr(Meta, "unknown") and Meta.unknown != marshmallow.EXCLUDE: + jsonschema["additionalProperties"] = Meta.unknown == marshmallow.INCLUDE + + return jsonschema +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c4d83b9a8bc2f850e4e558108b83eef98d02010c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:d8bbf65e97298cbc15be43723d0820e116e9330b54dc7dce3bddc825e0a9aeff" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..082fae424e085120c37f91b49f4f30482fdb3736 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..be9f5183b01f62791b6818a88ba2808850e0e2bd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/first-hunk-only.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index de7fbd2ad2f56c1fad264b4970bbffa404172d2b..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -110,8 +110,10 @@ + """ + try: + schema_instance = resolve_schema_instance(schema) ++ # If schema is a string and is not found in registry, ++ # assume it is a schema reference + except marshmallow.exceptions.RegistryError: +- return self.get_ref_dict(schema) # Changed output in case of RegistryError ++ return schema + schema_key = make_schema_key(schema_instance) + if schema_key not in self.refs: + name = self.schema_name_resolver(schema) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ukmznjln/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..a8c1b35da8b78291c0eb67fc25b4e828c655c352 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "52e016202e85f8cefd1f67076ede34b72cd5801ec60b20a48100e6db25412d5c", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "62f4fac7457591d8ac8d774a31622a406bb8967e3ed910d716aec8b9aa87e47d", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "d64972bf08f422ab1b472768b5800773581d5d876b64f710b9c03b0b81ce0cab", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "775ceff6eed9672305f1623370a120859eefe589", + "source_completion_sha256": "43e219334f366513efe0dd07dd7ccc5a9ea499bd5d02955348683e653b1c6462", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "2d4703122531fae837e932dd79b7d808c1da649399c3631364f116ede1e25c9f", + "is_fork": true, + "learner_path": "tasks/2c0eef0103ddd752fb63d481/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/775ceff6eed9672305f1623370a120859eefe589/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e1e27cf539367b94c825fda241f659201ebb08c4528e498f75993b510bee5c7e", + "provenance_path": "tasks/2c0eef0103ddd752fb63d481/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "775ceff6eed9672305f1623370a120859eefe589", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a89ad6a27bc2ee9671c22b384591affb40a9239a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "task_sha256": "f292c1b8b90f2b769e61d789874da73f63c6b2bc36b2ac5a05f631370b5bc9ef", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..390bbd38d6665d80c58ba87c3e724bd669089930 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/instruction.md @@ -0,0 +1,40 @@ +Schema field filtering broken with exclude/dump_only fields + +#### Description + +When using Marshmallow schemas with `exclude` or `dump_only` fields in the Meta class, the field filtering logic is not working correctly. Fields that should be excluded are being included, and fields that should be included are being excluded. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields + +class TestSchema(Schema): + field1 = fields.Str() + field2 = fields.Str(dump_only=True) + field3 = fields.Str() + + class Meta: + exclude = ['field3'] + dump_only = ['field2'] + +# When processing this schema, field filtering doesn't work as expected +# field3 should be excluded but appears in output +# field2 should be handled correctly for dump_only but isn't +``` + +The issue appears to be in the field filtering logic where `exclude` and `dump_only` field handling is mixed up, causing incorrect field inclusion/exclusion behavior. + +#### Expected Behavior + +- Fields listed in `Meta.exclude` should be filtered out +- Fields marked as `dump_only` should be handled according to the `exclude_dump_only` parameter +- The filtering should return the correctly filtered fields, not the original unfiltered fields + +#### Actual Behavior + +The field filtering returns incorrect results, with excluded fields appearing and dump_only fields not being handled properly. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..558c53353a078a7b6a6af57aeddf69b1356edc30 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "a89ad6a27bc2ee9671c22b384591affb40a9239a", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "775ceff6eed9672305f1623370a120859eefe589" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_common.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/common.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1020953, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "2d4703122531fae837e932dd79b7d808c1da649399c3631364f116ede1e25c9f", + "is_fork": true, + "learner_path": "tasks/2c0eef0103ddd752fb63d481/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/775ceff6eed9672305f1623370a120859eefe589/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e1e27cf539367b94c825fda241f659201ebb08c4528e498f75993b510bee5c7e", + "provenance_path": "tasks/2c0eef0103ddd752fb63d481/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "775ceff6eed9672305f1623370a120859eefe589", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a89ad6a27bc2ee9671c22b384591affb40a9239a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "task_sha256": "f292c1b8b90f2b769e61d789874da73f63c6b2bc36b2ac5a05f631370b5bc9ef", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..d60559c6fc5a4a4ce46ca9a7eaf005ebdc94c88e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "52e016202e85f8cefd1f67076ede34b72cd5801ec60b20a48100e6db25412d5c", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/775ceff6eed9672305f1623370a120859eefe589/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "43e219334f366513efe0dd07dd7ccc5a9ea499bd5d02955348683e653b1c6462", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "9a8e54a54bf800e9e44fb82494cddadfcdcfb6ad35b290a0a44458a8d2e2a689", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "2d4703122531fae837e932dd79b7d808c1da649399c3631364f116ede1e25c9f", + "is_fork": true, + "learner_path": "tasks/2c0eef0103ddd752fb63d481/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/775ceff6eed9672305f1623370a120859eefe589/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "e1e27cf539367b94c825fda241f659201ebb08c4528e498f75993b510bee5c7e", + "provenance_path": "tasks/2c0eef0103ddd752fb63d481/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "775ceff6eed9672305f1623370a120859eefe589", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a89ad6a27bc2ee9671c22b384591affb40a9239a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__ust4spt8", + "task_sha256": "f292c1b8b90f2b769e61d789874da73f63c6b2bc36b2ac5a05f631370b5bc9ef", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..01266358727b376cce3c9c7534c6b14c65b228f2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/provided-gold.diff @@ -0,0 +1,78 @@ +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 753fa70eb5e32518fbf8820581ac926a17ac5f5f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +@@ -95,17 +95,17 @@ + :param Meta: the schema's Meta class + :param bool exclude_dump_only: whether to filter dump_only fields + """ +- exclude = list(getattr(Meta, "dump_only", [])) ++ exclude = list(getattr(Meta, "exclude", [])) + if exclude_dump_only: +- exclude.extend(getattr(Meta, "exclude", [])) ++ exclude.extend(getattr(Meta, "dump_only", [])) + + filtered_fields = { + key: value + for key, value in fields.items() +- if key not in exclude and (exclude_dump_only or not value.dump_only) ++ if key not in exclude and not (exclude_dump_only and value.dump_only) + } + +- return fields ++ return filtered_fields + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: +@@ -119,14 +119,14 @@ + hash(attribute) + except TypeError: + # Unhashable iterable (list, set) +- attribute = list(attribute) # Change from frozenset to list +- modifiers.insert(0, attribute) # Change from append to insert at position 0 +- return tuple([schema.__class__, *reversed(modifiers)]) # Reverse the modifiers to their original order ++ attribute = frozenset(attribute) ++ modifiers.append(attribute) ++ return tuple([schema.__class__, *modifiers]) + + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -134,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -145,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7e6b078c7c53353e0ddefa375ec068e6021224b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/solution/solve.sh @@ -0,0 +1,84 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 753fa70eb5e32518fbf8820581ac926a17ac5f5f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +@@ -95,17 +95,17 @@ + :param Meta: the schema's Meta class + :param bool exclude_dump_only: whether to filter dump_only fields + """ +- exclude = list(getattr(Meta, "dump_only", [])) ++ exclude = list(getattr(Meta, "exclude", [])) + if exclude_dump_only: +- exclude.extend(getattr(Meta, "exclude", [])) ++ exclude.extend(getattr(Meta, "dump_only", [])) + + filtered_fields = { + key: value + for key, value in fields.items() +- if key not in exclude and (exclude_dump_only or not value.dump_only) ++ if key not in exclude and not (exclude_dump_only and value.dump_only) + } + +- return fields ++ return filtered_fields + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: +@@ -119,14 +119,14 @@ + hash(attribute) + except TypeError: + # Unhashable iterable (list, set) +- attribute = list(attribute) # Change from frozenset to list +- modifiers.insert(0, attribute) # Change from append to insert at position 0 +- return tuple([schema.__class__, *reversed(modifiers)]) # Reverse the modifiers to their original order ++ attribute = frozenset(attribute) ++ modifiers.append(attribute) ++ return tuple([schema.__class__, *modifiers]) + + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -134,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -145,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3ef39da28ac56b11dad06ff2dec3dec66ce24b73 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:4ab338088ec0684e2d38ecce5850044bef65cbc8c00befe0cd24ef1e19b290b2" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..5247a69e1111439efcb9709c677b94a3d79d34ca --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..f100ef9e02afca30256daea7c99d1b6cad21ad0a --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/first-hunk-only.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 753fa70eb5e32518fbf8820581ac926a17ac5f5f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__ust4spt8/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..e4d47629425957bf4bd56ce99cbecd5b4c889917 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "ce283de945fdd5e6419b6e4fcc6bd263b90db8db52673c49fe3cd4c05a94a054", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "d9fdbf3c700a31da37a6b41ce26ff45dc4e1fe16bdc81dc5d2feca6256adcf6c", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "66d8c0b9d8f76e25365056407697d60ec8207249de26c7f6e4a1d08f18f374b5", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "7b10aa94188db96565ba75dd78518b25448622fa", + "source_completion_sha256": "2e334c1ac58ad966357237d2159d916c361336aab464dcc21c55cf5778fa3204", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "619c77a7716d5e6b457b740fc858cea6ee241d0380e9c79ec49bbaac7c0e24b9", + "is_fork": true, + "learner_path": "tasks/501a4cac3e338645319cc143/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7b10aa94188db96565ba75dd78518b25448622fa/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "55ea3a86b9f1d669632165d8f5ac3fc90e9fc65696b511c06af09365721e64d4", + "provenance_path": "tasks/501a4cac3e338645319cc143/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7b10aa94188db96565ba75dd78518b25448622fa", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8483d3706c7d43970c3fdb5965668a68180c09b7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "task_sha256": "ae80ac0fa4c4ef43465dd3f3e1caabbcbe42a6dcf7910af4dba54208b7ff8de7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b8a749e8416d607fe2c014bf040d74b7cefd8c2f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/instruction.md @@ -0,0 +1,33 @@ +Schema resolution broken after recent changes + +#### Description + +After some recent changes, schema resolution is not working properly. When trying to use schemas in API specs, I'm getting unexpected behavior where the schema resolution logic seems to be failing. + +#### Steps/Code to Reproduce + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +from marshmallow import Schema, fields + +class PetSchema(Schema): + name = fields.Str() + age = fields.Int() + +spec = APISpec( + title="Test API", + version="1.0.0", + openapi_version="3.0.0", + plugins=[MarshmallowPlugin()] +) + +# This should work but doesn't +spec.components.schema('Pet', schema=PetSchema) +``` + +The schema registration process appears to be broken and schemas aren't being resolved correctly when referenced in API paths or components. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..c5b7ac870deed727baf4f48fb12c93dbc531edc3 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "8483d3706c7d43970c3fdb5965668a68180c09b7", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "7b10aa94188db96565ba75dd78518b25448622fa" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_common.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/common.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1020607, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "619c77a7716d5e6b457b740fc858cea6ee241d0380e9c79ec49bbaac7c0e24b9", + "is_fork": true, + "learner_path": "tasks/501a4cac3e338645319cc143/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7b10aa94188db96565ba75dd78518b25448622fa/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "55ea3a86b9f1d669632165d8f5ac3fc90e9fc65696b511c06af09365721e64d4", + "provenance_path": "tasks/501a4cac3e338645319cc143/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7b10aa94188db96565ba75dd78518b25448622fa", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8483d3706c7d43970c3fdb5965668a68180c09b7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "task_sha256": "ae80ac0fa4c4ef43465dd3f3e1caabbcbe42a6dcf7910af4dba54208b7ff8de7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..280bcf4032ca087319bc8d55e52c575b5b9b0a10 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "ce283de945fdd5e6419b6e4fcc6bd263b90db8db52673c49fe3cd4c05a94a054", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7b10aa94188db96565ba75dd78518b25448622fa/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "2e334c1ac58ad966357237d2159d916c361336aab464dcc21c55cf5778fa3204", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "f76f59d029e61218addfc007566d93343a6860b51730a2d3a18645b5bc6cf173", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "619c77a7716d5e6b457b740fc858cea6ee241d0380e9c79ec49bbaac7c0e24b9", + "is_fork": true, + "learner_path": "tasks/501a4cac3e338645319cc143/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7b10aa94188db96565ba75dd78518b25448622fa/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "55ea3a86b9f1d669632165d8f5ac3fc90e9fc65696b511c06af09365721e64d4", + "provenance_path": "tasks/501a4cac3e338645319cc143/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7b10aa94188db96565ba75dd78518b25448622fa", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8483d3706c7d43970c3fdb5965668a68180c09b7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wrir0rde", + "task_sha256": "ae80ac0fa4c4ef43465dd3f3e1caabbcbe42a6dcf7910af4dba54208b7ff8de7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..a60b25ab520a6f29154453808b46af246ca87d43 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/provided-gold.diff @@ -0,0 +1,68 @@ +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188601a1c6f5cd5584129d501eb01096ba97f5ac..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -17,9 +17,6 @@ + def resolve_schema_instance( + schema: type[marshmallow.Schema] | marshmallow.Schema | str, + ) -> marshmallow.Schema: +- if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema)() + """Return schema instance for given schema (instance or class). + + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema +@@ -27,6 +24,10 @@ + """ + if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): + return schema() ++ if isinstance(schema, marshmallow.Schema): ++ return schema ++ return marshmallow.class_registry.get_class(schema)() ++ + + def resolve_schema_cls( + schema: type[marshmallow.Schema] | str | marshmallow.Schema, +@@ -108,6 +109,8 @@ + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: ++ if not isinstance(schema, marshmallow.Schema): ++ raise TypeError("can only make a schema key based on a Schema instance.") + modifiers = [] + for modifier in MODIFIERS: + attribute = getattr(schema, modifier) +@@ -118,13 +121,12 @@ + # Unhashable iterable (list, set) + attribute = frozenset(attribute) + modifiers.append(attribute) +- if not isinstance(schema, marshmallow.Schema): +- raise TypeError("can only make a schema key based on a Schema instance.") + return tuple([schema.__class__, *modifiers]) ++ + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -132,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -143,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71a939b092a66f8f59e73abe556f545ff6f51db6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/solution/solve.sh @@ -0,0 +1,74 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188601a1c6f5cd5584129d501eb01096ba97f5ac..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -17,9 +17,6 @@ + def resolve_schema_instance( + schema: type[marshmallow.Schema] | marshmallow.Schema | str, + ) -> marshmallow.Schema: +- if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema)() + """Return schema instance for given schema (instance or class). + + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema +@@ -27,6 +24,10 @@ + """ + if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): + return schema() ++ if isinstance(schema, marshmallow.Schema): ++ return schema ++ return marshmallow.class_registry.get_class(schema)() ++ + + def resolve_schema_cls( + schema: type[marshmallow.Schema] | str | marshmallow.Schema, +@@ -108,6 +109,8 @@ + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: ++ if not isinstance(schema, marshmallow.Schema): ++ raise TypeError("can only make a schema key based on a Schema instance.") + modifiers = [] + for modifier in MODIFIERS: + attribute = getattr(schema, modifier) +@@ -118,13 +121,12 @@ + # Unhashable iterable (list, set) + attribute = frozenset(attribute) + modifiers.append(attribute) +- if not isinstance(schema, marshmallow.Schema): +- raise TypeError("can only make a schema key based on a Schema instance.") + return tuple([schema.__class__, *modifiers]) ++ + + def get_unique_schema_name(components: Components, name: str, counter: int = 0) -> str: + """Function to generate a unique name based on the provided name and names +- already in the spec. Will append a number to the name to make it unique if ++ already in the spec. Will append a number to the name to make it unique if + the name is already in the spec. + + :param Components components: instance of the components of the spec +@@ -132,7 +134,7 @@ + :param int counter: the counter of the number of recursions + :return: the unique name + """ +- if name not in components.schemas and counter > 0: ++ if name not in components.schemas: + return name + if not counter: # first time through recursion + warnings.warn( +@@ -143,6 +145,6 @@ + stacklevel=2, + ) + else: # subsequent recursions +- name = name[:-len(str(counter)) - 1] +- counter -= 1 ++ name = name[: -len(str(counter))] ++ counter += 1 + return get_unique_schema_name(components, name + str(counter), counter) +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..147e58d7caf54bf864f13a51e811c56e661870c5 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:173d62c570569f08137bb3bbf453c6e5992bff43e6bd1f268945d227b164d738" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..df1027e882632c5aed9c8398fc35c90b13f4aca0 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..25751ea26f5938d370b9e87f78a37a07c1009a7a --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/first-hunk-only.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188601a1c6f5cd5584129d501eb01096ba97f5ac..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -17,9 +17,6 @@ + def resolve_schema_instance( + schema: type[marshmallow.Schema] | marshmallow.Schema | str, + ) -> marshmallow.Schema: +- if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema)() + """Return schema instance for given schema (instance or class). + + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wrir0rde/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..44a86f256c580cf86184342ad3dbe9015e2bc3e7 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "27e46644907d07e02f59c6af8cc5ae44d77bd83afb22778e54af1161446bf4e2", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "d0302fa9acabd2ddfec10c5e03bfccb5c516f5d8d72615f1a6ac9e0ad09bcf66", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "5bb5aa34a79c02312c8e5e9448b0b303782c572c41a403d735bf34c6fb4a9384", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "7ac24c491ab1dde3a344702735dbf6b81406d1c2", + "source_completion_sha256": "88b7aa83729b27ce200c9d7325734fdf63faa764ace15d9fa8711e0dd543df5a", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8256b286168ff0917bc7599fe75321fc4e7956f87fe316cae236103d9e04770f", + "is_fork": true, + "learner_path": "tasks/07f71baaaebb5e7e092127c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7ac24c491ab1dde3a344702735dbf6b81406d1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "756df31e0fb446eafd0fff1d316e49d92b65111b30ba0991d5adccc21ef6aa2a", + "provenance_path": "tasks/07f71baaaebb5e7e092127c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7ac24c491ab1dde3a344702735dbf6b81406d1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ed07e52ada30d665f66f1833934d8516df632a6a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "task_sha256": "846a4530a826966c0ed574361db95efb2c03284c5d746206759016b8fcb186cb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0986cbf018946de8c64932e73b58e7e88b41d5bf --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/instruction.md @@ -0,0 +1,37 @@ +YAML utilities return unexpected values for empty docstrings + +#### Description + +When using `load_yaml_from_docstring` with empty or None docstrings, the function returns unexpected values instead of empty dictionaries. Additionally, `dict_to_yaml` behavior has changed regarding key sorting and flow style defaults. + +#### Steps/Code to Reproduce + +```python +from apispec import yaml_utils + +# This should return {} but returns something else +result = yaml_utils.load_yaml_from_docstring(None) +print(f"None docstring result: {result}") + +result = yaml_utils.load_yaml_from_docstring('') +print(f"Empty docstring result: {result}") + +result = yaml_utils.load_yaml_from_docstring('---') +print(f"--- docstring result: {result}") + +# Key ordering behavior changed +result = yaml_utils.dict_to_yaml({'herp': 1, 'derp': 2}) +print(f"Dict to YAML result: {repr(result)}") +# Expected: 'herp: 1\nderp: 2\n' + +# Unicode handling changed +result = yaml_utils.dict_to_yaml({'가': '나'}) +print(f"Unicode result: {repr(result)}") +# Expected: '"\\uAC00": "\\uB098"\n' +``` + +The functions are returning different types/values than expected, breaking existing code that relies on consistent return types. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..8959b0ca54e75a4874e3f441e5b110bb64acc395 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "ed07e52ada30d665f66f1833934d8516df632a6a", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "7ac24c491ab1dde3a344702735dbf6b81406d1c2" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_ext_marshmallow_field.py", + "/testbed/tests/test_ext_marshmallow_openapi.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_yaml_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/yaml_utils.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1122056, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8256b286168ff0917bc7599fe75321fc4e7956f87fe316cae236103d9e04770f", + "is_fork": true, + "learner_path": "tasks/07f71baaaebb5e7e092127c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7ac24c491ab1dde3a344702735dbf6b81406d1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "756df31e0fb446eafd0fff1d316e49d92b65111b30ba0991d5adccc21ef6aa2a", + "provenance_path": "tasks/07f71baaaebb5e7e092127c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7ac24c491ab1dde3a344702735dbf6b81406d1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ed07e52ada30d665f66f1833934d8516df632a6a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "task_sha256": "846a4530a826966c0ed574361db95efb2c03284c5d746206759016b8fcb186cb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..f226cfd9a8d0bd2dd7a58137bf9c1e150ba5f34f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "27e46644907d07e02f59c6af8cc5ae44d77bd83afb22778e54af1161446bf4e2", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7ac24c491ab1dde3a344702735dbf6b81406d1c2/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "88b7aa83729b27ce200c9d7325734fdf63faa764ace15d9fa8711e0dd543df5a", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "2a0bb23a128daf4d49c56c7fd471d943ecdedf826e20c28379fbb4670032bc49", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8256b286168ff0917bc7599fe75321fc4e7956f87fe316cae236103d9e04770f", + "is_fork": true, + "learner_path": "tasks/07f71baaaebb5e7e092127c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/7ac24c491ab1dde3a344702735dbf6b81406d1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "756df31e0fb446eafd0fff1d316e49d92b65111b30ba0991d5adccc21ef6aa2a", + "provenance_path": "tasks/07f71baaaebb5e7e092127c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "7ac24c491ab1dde3a344702735dbf6b81406d1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ed07e52ada30d665f66f1833934d8516df632a6a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wty5qg00", + "task_sha256": "846a4530a826966c0ed574361db95efb2c03284c5d746206759016b8fcb186cb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..8820f790e86b0d989f05c3690e71455a978f2b1e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/provided-gold.diff @@ -0,0 +1,39 @@ +diff --git a/src/apispec/yaml_utils.py b/src/apispec/yaml_utils.py +index 219544c969b9fc56f097746e5ffe824d9789ae77..52985dc52bffc9d8bb25d6447e0caddd1a04fa60 100644 +--- a/src/apispec/yaml_utils.py ++++ b/src/apispec/yaml_utils.py +@@ -11,9 +11,10 @@ + + def dict_to_yaml(dic: dict, yaml_dump_kwargs: typing.Any | None = None) -> str: + """Serializes a dictionary to YAML.""" +- yaml_dump_kwargs = yaml_dump_kwargs or {"sort_keys": True} ++ yaml_dump_kwargs = yaml_dump_kwargs or {} + +- yaml_dump_kwargs.setdefault("default_flow_style", True) ++ # By default, don't sort alphabetically to respect schema field ordering ++ yaml_dump_kwargs.setdefault("sort_keys", False) + return yaml.dump(dic, **yaml_dump_kwargs) + + +@@ -21,17 +22,18 @@ + """Loads YAML from docstring.""" + split_lines = trim_docstring(docstring).split("\n") + ++ # Cut YAML from rest of docstring + for index, line in enumerate(split_lines): + line = line.strip() + if line.startswith("---"): +- cut_from = index + 1 ++ cut_from = index + break + else: +- return None ++ return {} + + yaml_string = "\n".join(split_lines[cut_from:]) + yaml_string = dedent(yaml_string) +- return yaml.safe_load(yaml_string) or [] ++ return yaml.safe_load(yaml_string) or {} + + + PATH_KEYS = {"get", "put", "post", "delete", "options", "head", "patch"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7c9998925691fe0f303e16849ce159fe16124a90 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/solution/solve.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/yaml_utils.py b/src/apispec/yaml_utils.py +index 219544c969b9fc56f097746e5ffe824d9789ae77..52985dc52bffc9d8bb25d6447e0caddd1a04fa60 100644 +--- a/src/apispec/yaml_utils.py ++++ b/src/apispec/yaml_utils.py +@@ -11,9 +11,10 @@ + + def dict_to_yaml(dic: dict, yaml_dump_kwargs: typing.Any | None = None) -> str: + """Serializes a dictionary to YAML.""" +- yaml_dump_kwargs = yaml_dump_kwargs or {"sort_keys": True} ++ yaml_dump_kwargs = yaml_dump_kwargs or {} + +- yaml_dump_kwargs.setdefault("default_flow_style", True) ++ # By default, don't sort alphabetically to respect schema field ordering ++ yaml_dump_kwargs.setdefault("sort_keys", False) + return yaml.dump(dic, **yaml_dump_kwargs) + + +@@ -21,17 +22,18 @@ + """Loads YAML from docstring.""" + split_lines = trim_docstring(docstring).split("\n") + ++ # Cut YAML from rest of docstring + for index, line in enumerate(split_lines): + line = line.strip() + if line.startswith("---"): +- cut_from = index + 1 ++ cut_from = index + break + else: +- return None ++ return {} + + yaml_string = "\n".join(split_lines[cut_from:]) + yaml_string = dedent(yaml_string) +- return yaml.safe_load(yaml_string) or [] ++ return yaml.safe_load(yaml_string) or {} + + + PATH_KEYS = {"get", "put", "post", "delete", "options", "head", "patch"} +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d07a76ac06aa33201b65c8c4c04748f34a24db5f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:1b8a6a9a32d2163b496990bf8fb154c163f4081d692f9f8c963c4bd4d5cd1c46" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..69f120c800513ea88cf0380c13f1e80387076991 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..7bf906b2818d42aab96bfa87de5de9754a66facc --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/first-hunk-only.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/yaml_utils.py b/src/apispec/yaml_utils.py +index 219544c969b9fc56f097746e5ffe824d9789ae77..52985dc52bffc9d8bb25d6447e0caddd1a04fa60 100644 +--- a/src/apispec/yaml_utils.py ++++ b/src/apispec/yaml_utils.py +@@ -11,9 +11,10 @@ + + def dict_to_yaml(dic: dict, yaml_dump_kwargs: typing.Any | None = None) -> str: + """Serializes a dictionary to YAML.""" +- yaml_dump_kwargs = yaml_dump_kwargs or {"sort_keys": True} ++ yaml_dump_kwargs = yaml_dump_kwargs or {} + +- yaml_dump_kwargs.setdefault("default_flow_style", True) ++ # By default, don't sort alphabetically to respect schema field ordering ++ yaml_dump_kwargs.setdefault("sort_keys", False) + return yaml.dump(dic, **yaml_dump_kwargs) + + +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wty5qg00/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..a4642f562b01b98e75cbf676cba164d07b8241a6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "7815f742553cb1328e58e6362ab7fe353aaaf27d0dc4ea4a471ac67d2ca3d7c4", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "0ff583be359ef878a771b4e5bbb0250960aecf280ba134de04769509d2952c3a", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "2a043601ecc7fdb01434854b3fcb6bad9021c84993b0c6ceb32623db6b905543", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "ba18079a5763da472d0fe9459a3a7e5e977f71d5", + "source_completion_sha256": "221a21d8292debb662041018a5a3c1c844fccfcddf0afb9bbf927fde55600365", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "df6ad519adcc85fece51a221a35fdde89f182f73960c8c60ab8e218017bbc9bd", + "is_fork": true, + "learner_path": "tasks/8215639d6199afd64634e15d/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/ba18079a5763da472d0fe9459a3a7e5e977f71d5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "6eb34ef26475f770a1f38e018f53fb4fcf7eb43f1d2146fc3a89a8b849afc938", + "provenance_path": "tasks/8215639d6199afd64634e15d/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ba18079a5763da472d0fe9459a3a7e5e977f71d5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8e77e8b687b49e8bf06b1b2358690b9b08f07c6b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "task_sha256": "4342e1673e3e8dc74498bae22f937f7790fe2ed9210e20115e908b48f1b6b46d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c3540ab357b52f4ceb75059650c2ca6bfda21d6b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/instruction.md @@ -0,0 +1,77 @@ +# Multiple issues with OpenAPIConverter in marshmallow extension + +I've found several issues with the OpenAPIConverter class in the marshmallow extension that break schema resolution and parameter handling. + +## Issues + +1. The `schema_name_resolver` is being set to `None` in the constructor, which breaks schema resolution +2. The initialization order is wrong - `init_attribute_functions()` is called after `init_parameter_attribute_functions()` +3. The `refs` dictionary is initialized as a list `[]` instead of a dict `{}` +4. In the `register_parameter_attribute_function`, the function is being set directly instead of the bound method +5. The `resolve_nested_schema` method has several issues: + - It returns `schema_instance` instead of `self.get_ref_dict(schema_instance)` + - It swaps the order of registering a schema and getting a unique name + - It changes the default for `many` from `False` to `True` +6. The `field2parameter_style` method has incorrect values: + - For OpenAPI 3, it uses "matrix" style instead of "form" + - For OpenAPI 3, it sets `explode` to `False` instead of `True` + - For OpenAPI < 3, it checks `<=` instead of `<` + - For OpenAPI < 3, it uses "csv" instead of "multi" + +## Reproduction + +Here's a simple example that demonstrates the issue: + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +from marshmallow import Schema, fields + +class PetSchema(Schema): + id = fields.Int() + name = fields.Str() + +# Create spec +spec = APISpec( + title="Pets API", + version="1.0.0", + openapi_version="3.0.0", + plugins=[MarshmallowPlugin()], +) + +# Try to add a schema +spec.components.schema("Pet", schema=PetSchema) + +# Try to use the schema in a path +spec.path( + path="/pets/{pet_id}", + operations={ + "get": { + "parameters": [ + {"name": "pet_id", "in": "path", "required": True, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "Return a pet", + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } +) + +# This will fail with various errors depending on which part you're using +print(spec.to_dict()) +``` + +The issues cause various failures when trying to resolve nested schemas, register parameter attributes, or generate OpenAPI specs with proper schema references. + + + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..a1f94d7d9cd68e5787d8727d5521c55c71e5a593 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "8e77e8b687b49e8bf06b1b2358690b9b08f07c6b", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "ba18079a5763da472d0fe9459a3a7e5e977f71d5" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/openapi.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1024015, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "df6ad519adcc85fece51a221a35fdde89f182f73960c8c60ab8e218017bbc9bd", + "is_fork": true, + "learner_path": "tasks/8215639d6199afd64634e15d/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/ba18079a5763da472d0fe9459a3a7e5e977f71d5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "6eb34ef26475f770a1f38e018f53fb4fcf7eb43f1d2146fc3a89a8b849afc938", + "provenance_path": "tasks/8215639d6199afd64634e15d/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ba18079a5763da472d0fe9459a3a7e5e977f71d5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8e77e8b687b49e8bf06b1b2358690b9b08f07c6b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "task_sha256": "4342e1673e3e8dc74498bae22f937f7790fe2ed9210e20115e908b48f1b6b46d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..0d0e3a4661a45084427a425a36af1f5121cc5338 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "7815f742553cb1328e58e6362ab7fe353aaaf27d0dc4ea4a471ac67d2ca3d7c4", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/ba18079a5763da472d0fe9459a3a7e5e977f71d5/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "221a21d8292debb662041018a5a3c1c844fccfcddf0afb9bbf927fde55600365", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "53d120dea469a1cdd39596f186d3e5b20dbcf459a8ebdb1e05a71450ebebf466", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "df6ad519adcc85fece51a221a35fdde89f182f73960c8c60ab8e218017bbc9bd", + "is_fork": true, + "learner_path": "tasks/8215639d6199afd64634e15d/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/ba18079a5763da472d0fe9459a3a7e5e977f71d5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "6eb34ef26475f770a1f38e018f53fb4fcf7eb43f1d2146fc3a89a8b849afc938", + "provenance_path": "tasks/8215639d6199afd64634e15d/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ba18079a5763da472d0fe9459a3a7e5e977f71d5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8e77e8b687b49e8bf06b1b2358690b9b08f07c6b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__wvsln54a", + "task_sha256": "4342e1673e3e8dc74498bae22f937f7790fe2ed9210e20115e908b48f1b6b46d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..f74e36160051a02079378f607ce273d25ab0b801 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/provided-gold.diff @@ -0,0 +1,76 @@ +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 76645be8d39048d98f616684a4b22ce5164a0533..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -62,12 +62,12 @@ + if isinstance(openapi_version, str) + else openapi_version + ) +- self.schema_name_resolver = None ++ self.schema_name_resolver = schema_name_resolver + self.spec = spec ++ self.init_attribute_functions() + self.init_parameter_attribute_functions() +- self.init_attribute_functions() + # Schema references +- self.refs: dict = [] ++ self.refs: dict = {} + + def init_parameter_attribute_functions(self) -> None: + self.parameter_attribute_functions = [ +@@ -93,8 +93,8 @@ + field parameter functions in the order they were added. + """ + bound_func = func.__get__(self) +- setattr(self, func.__name__, func) +- self.parameter_attribute_functions.insert(0, bound_func) ++ setattr(self, func.__name__, bound_func) ++ self.parameter_attribute_functions.append(bound_func) + + def resolve_nested_schema(self, schema): + """Return the OpenAPI representation of a marshmallow Schema. +@@ -110,8 +110,10 @@ + """ + try: + schema_instance = resolve_schema_instance(schema) ++ # If schema is a string and is not found in registry, ++ # assume it is a schema reference + except marshmallow.exceptions.RegistryError: +- return self.get_ref_dict(schema) # Changed output in case of RegistryError ++ return schema + schema_key = make_schema_key(schema_instance) + if schema_key not in self.refs: + name = self.schema_name_resolver(schema) +@@ -126,12 +128,12 @@ + " MarshmallowPlugin returns a string for all circular" + " referencing schemas." + ) from exc +- if getattr(schema, "many", True): # Changed False to True here ++ if getattr(schema, "many", False): + return {"type": "array", "items": json_schema} + return json_schema +- self.spec.components.schema(name, schema=schema_instance) # Changed schema to schema_instance +- name = get_unique_schema_name(self.spec.components, name) # Swapped order with the previous line +- return schema_instance # Changed self.get_ref_dict(schema_instance) to schema_instance ++ name = get_unique_schema_name(self.spec.components, name) ++ self.spec.components.schema(name, schema=schema) ++ return self.get_ref_dict(schema_instance) + + def schema2parameters( + self, +@@ -229,11 +231,11 @@ + """ + ret: dict = {} + if isinstance(field, marshmallow.fields.List): +- if self.openapi_version.major <= 3: +- ret["collectionFormat"] = "csv" ++ if self.openapi_version.major < 3: ++ ret["collectionFormat"] = "multi" + else: +- ret["explode"] = False +- ret["style"] = "matrix" ++ ret["explode"] = True ++ ret["style"] = "form" + return ret + + def schema2jsonschema(self, schema): diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..abbb8fb9bd7eef33c68f89cf63448f94c05a183e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/solution/solve.sh @@ -0,0 +1,82 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 76645be8d39048d98f616684a4b22ce5164a0533..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -62,12 +62,12 @@ + if isinstance(openapi_version, str) + else openapi_version + ) +- self.schema_name_resolver = None ++ self.schema_name_resolver = schema_name_resolver + self.spec = spec ++ self.init_attribute_functions() + self.init_parameter_attribute_functions() +- self.init_attribute_functions() + # Schema references +- self.refs: dict = [] ++ self.refs: dict = {} + + def init_parameter_attribute_functions(self) -> None: + self.parameter_attribute_functions = [ +@@ -93,8 +93,8 @@ + field parameter functions in the order they were added. + """ + bound_func = func.__get__(self) +- setattr(self, func.__name__, func) +- self.parameter_attribute_functions.insert(0, bound_func) ++ setattr(self, func.__name__, bound_func) ++ self.parameter_attribute_functions.append(bound_func) + + def resolve_nested_schema(self, schema): + """Return the OpenAPI representation of a marshmallow Schema. +@@ -110,8 +110,10 @@ + """ + try: + schema_instance = resolve_schema_instance(schema) ++ # If schema is a string and is not found in registry, ++ # assume it is a schema reference + except marshmallow.exceptions.RegistryError: +- return self.get_ref_dict(schema) # Changed output in case of RegistryError ++ return schema + schema_key = make_schema_key(schema_instance) + if schema_key not in self.refs: + name = self.schema_name_resolver(schema) +@@ -126,12 +128,12 @@ + " MarshmallowPlugin returns a string for all circular" + " referencing schemas." + ) from exc +- if getattr(schema, "many", True): # Changed False to True here ++ if getattr(schema, "many", False): + return {"type": "array", "items": json_schema} + return json_schema +- self.spec.components.schema(name, schema=schema_instance) # Changed schema to schema_instance +- name = get_unique_schema_name(self.spec.components, name) # Swapped order with the previous line +- return schema_instance # Changed self.get_ref_dict(schema_instance) to schema_instance ++ name = get_unique_schema_name(self.spec.components, name) ++ self.spec.components.schema(name, schema=schema) ++ return self.get_ref_dict(schema_instance) + + def schema2parameters( + self, +@@ -229,11 +231,11 @@ + """ + ret: dict = {} + if isinstance(field, marshmallow.fields.List): +- if self.openapi_version.major <= 3: +- ret["collectionFormat"] = "csv" ++ if self.openapi_version.major < 3: ++ ret["collectionFormat"] = "multi" + else: +- ret["explode"] = False +- ret["style"] = "matrix" ++ ret["explode"] = True ++ ret["style"] = "form" + return ret + + def schema2jsonschema(self, schema): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..c281b5b4901b8ebd554682ced7b6f449cb8dadf6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:1949a5320fe2c4af1f4b01c90ffb8fd692e39e11798f37bba231a5e83c6bb2c1" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..35f4f4dc35219529c92230f2d39ab25229e017e1 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..4466c4693a666a44830b837c56727b96ac393fd4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/first-hunk-only.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 76645be8d39048d98f616684a4b22ce5164a0533..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -62,12 +62,12 @@ + if isinstance(openapi_version, str) + else openapi_version + ) +- self.schema_name_resolver = None ++ self.schema_name_resolver = schema_name_resolver + self.spec = spec ++ self.init_attribute_functions() + self.init_parameter_attribute_functions() +- self.init_attribute_functions() + # Schema references +- self.refs: dict = [] ++ self.refs: dict = {} + + def init_parameter_attribute_functions(self) -> None: + self.parameter_attribute_functions = [ +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__wvsln54a/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..20d09184e409657fe98c687a26dc5c0a8040f707 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "1bc5d9fe9fa73b81795a4de8ce7ea3f2f41c6e34d9459ef015b4c4809152a48d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "7ed23f4f2dce837fa8224951a8355f485ebd184ddb26fadc701359dda4389e61", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "1eb7fa8396d5e675f7e383b6d2605b8f8b9a732801f679b4ab57904f9e6e1338", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "9125c35f2b21dc6b7269680e4b1be60d80d33026", + "source_completion_sha256": "2f05cffdf333cf573413f0d503142114a0c9c52aaaf251fc57528e36fd7bc9f5", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "77405010feb07f7b4d83dcd58191f5e3e5c0fda4937cd6e3dc10491567f2c0ce", + "is_fork": true, + "learner_path": "tasks/9ea3d8660e896e13216fd0c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/9125c35f2b21dc6b7269680e4b1be60d80d33026/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "b08bed292362af1ae8db763f4c2c21afcec2f19e1a257a0db02d38e3f91b1948", + "provenance_path": "tasks/9ea3d8660e896e13216fd0c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "9125c35f2b21dc6b7269680e4b1be60d80d33026", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "28cd7bc19ee77a701713ff04d0881177be88c91e", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "task_sha256": "811b2d44405a75b432ad1178bcc63c922e58598b8d9b024874791a1f9ef285a5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..824ea38a6259757b8cbab00b3a94ea199decec27 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/instruction.md @@ -0,0 +1,48 @@ +Schema field filtering broken after recent changes + +#### Description + +The marshmallow schema field filtering logic appears to be completely broken. When trying to use schemas with excluded fields or dump_only fields, the filtering is not working correctly and returning unexpected results. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields +from apispec.ext.marshmallow.common import get_fields + +class TestSchema(Schema): + field1 = fields.Str() + field2 = fields.Str(dump_only=True) + field3 = fields.Str() + + class Meta: + exclude = ('field3',) + +# This should return only field1, but returns unexpected results +result = get_fields(TestSchema, exclude_dump_only=True) +print("Fields returned:", list(result.keys())) +print("Expected: ['field1']") +``` + +Also affects nested schema handling: + +```python +class ChildSchema(Schema): + name = fields.Str() + +class ParentSchema(Schema): + child = fields.Nested(ChildSchema) + excluded_field = fields.Str() + + class Meta: + exclude = ('excluded_field',) + +# Schema processing fails completely +result = get_fields(ParentSchema) +``` + +The field filtering logic seems to have gotten mixed up - fields that should be excluded are being included, and the exclude_dump_only parameter behavior is inverted. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..870a51401f8691cd00afbe60d9bfbdcb32983afa --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "28cd7bc19ee77a701713ff04d0881177be88c91e", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "9125c35f2b21dc6b7269680e4b1be60d80d33026" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_common.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/common.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1020305, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "77405010feb07f7b4d83dcd58191f5e3e5c0fda4937cd6e3dc10491567f2c0ce", + "is_fork": true, + "learner_path": "tasks/9ea3d8660e896e13216fd0c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/9125c35f2b21dc6b7269680e4b1be60d80d33026/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "b08bed292362af1ae8db763f4c2c21afcec2f19e1a257a0db02d38e3f91b1948", + "provenance_path": "tasks/9ea3d8660e896e13216fd0c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "9125c35f2b21dc6b7269680e4b1be60d80d33026", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "28cd7bc19ee77a701713ff04d0881177be88c91e", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "task_sha256": "811b2d44405a75b432ad1178bcc63c922e58598b8d9b024874791a1f9ef285a5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..69fa06d2dbe1d24ca2d2f66535f693903b0b34ee --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "1bc5d9fe9fa73b81795a4de8ce7ea3f2f41c6e34d9459ef015b4c4809152a48d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/9125c35f2b21dc6b7269680e4b1be60d80d33026/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "2f05cffdf333cf573413f0d503142114a0c9c52aaaf251fc57528e36fd7bc9f5", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "f64008d15b6407555c6517d6c21964851578bfd9967512e6a49ac81b91dc3c69", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "77405010feb07f7b4d83dcd58191f5e3e5c0fda4937cd6e3dc10491567f2c0ce", + "is_fork": true, + "learner_path": "tasks/9ea3d8660e896e13216fd0c2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/9125c35f2b21dc6b7269680e4b1be60d80d33026/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "b08bed292362af1ae8db763f4c2c21afcec2f19e1a257a0db02d38e3f91b1948", + "provenance_path": "tasks/9ea3d8660e896e13216fd0c2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "9125c35f2b21dc6b7269680e4b1be60d80d33026", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "28cd7bc19ee77a701713ff04d0881177be88c91e", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__x34b5zjs", + "task_sha256": "811b2d44405a75b432ad1178bcc63c922e58598b8d9b024874791a1f9ef285a5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..7b780bc7530872a41dba8462391d4da63f5d0551 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/provided-gold.diff @@ -0,0 +1,59 @@ +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188707b2a90f33df3792a692ac881ff91542156f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -38,10 +38,10 @@ + :return: schema class of given schema (instance or class) + """ + if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return [schema] ++ return schema + if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema) ++ return type(schema) ++ return marshmallow.class_registry.get_class(str(schema)) + + + def get_fields( +@@ -56,13 +56,14 @@ + :rtype: dict, of field name field object pairs + """ + if isinstance(schema, marshmallow.Schema): +- fields = copy.deepcopy(schema.fields) ++ fields = schema.fields + elif isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- fields = schema._declared_fields ++ fields = copy.deepcopy(schema._declared_fields) + else: +- return {} ++ raise ValueError(f"{schema!r} is neither a Schema class nor a Schema instance.") + Meta = getattr(schema, "Meta", None) +- return filter_excluded_fields(fields, Meta, exclude_dump_only=not exclude_dump_only) ++ warn_if_fields_defined_in_meta(fields, Meta) ++ return filter_excluded_fields(fields, Meta, exclude_dump_only=exclude_dump_only) + + + def warn_if_fields_defined_in_meta(fields: dict[str, fields.Field], Meta): +@@ -94,17 +95,17 @@ + :param Meta: the schema's Meta class + :param bool exclude_dump_only: whether to filter dump_only fields + """ +- exclude = list(getattr(Meta, "dump_only", [])) ++ exclude = list(getattr(Meta, "exclude", [])) + if exclude_dump_only: +- exclude.extend(getattr(Meta, "exclude", [])) ++ exclude.extend(getattr(Meta, "dump_only", [])) + + filtered_fields = { + key: value + for key, value in fields.items() +- if key not in exclude and (exclude_dump_only or not value.dump_only) ++ if key not in exclude and not (exclude_dump_only and value.dump_only) + } + +- return fields ++ return filtered_fields + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b12f28ecba47971ed58a9780ca9d70270896aae7 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/solution/solve.sh @@ -0,0 +1,65 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188707b2a90f33df3792a692ac881ff91542156f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -38,10 +38,10 @@ + :return: schema class of given schema (instance or class) + """ + if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return [schema] ++ return schema + if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema) ++ return type(schema) ++ return marshmallow.class_registry.get_class(str(schema)) + + + def get_fields( +@@ -56,13 +56,14 @@ + :rtype: dict, of field name field object pairs + """ + if isinstance(schema, marshmallow.Schema): +- fields = copy.deepcopy(schema.fields) ++ fields = schema.fields + elif isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- fields = schema._declared_fields ++ fields = copy.deepcopy(schema._declared_fields) + else: +- return {} ++ raise ValueError(f"{schema!r} is neither a Schema class nor a Schema instance.") + Meta = getattr(schema, "Meta", None) +- return filter_excluded_fields(fields, Meta, exclude_dump_only=not exclude_dump_only) ++ warn_if_fields_defined_in_meta(fields, Meta) ++ return filter_excluded_fields(fields, Meta, exclude_dump_only=exclude_dump_only) + + + def warn_if_fields_defined_in_meta(fields: dict[str, fields.Field], Meta): +@@ -94,17 +95,17 @@ + :param Meta: the schema's Meta class + :param bool exclude_dump_only: whether to filter dump_only fields + """ +- exclude = list(getattr(Meta, "dump_only", [])) ++ exclude = list(getattr(Meta, "exclude", [])) + if exclude_dump_only: +- exclude.extend(getattr(Meta, "exclude", [])) ++ exclude.extend(getattr(Meta, "dump_only", [])) + + filtered_fields = { + key: value + for key, value in fields.items() +- if key not in exclude and (exclude_dump_only or not value.dump_only) ++ if key not in exclude and not (exclude_dump_only and value.dump_only) + } + +- return fields ++ return filtered_fields + + + def make_schema_key(schema: marshmallow.Schema) -> tuple[type[marshmallow.Schema], ...]: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..f50df0f6eb43574608312fd54f7e5dabe6aad4da --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:20b8643b718d57eda4078c691d8da4eee60a63427327168b7cab62f95624b62c" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..9e64484001dd4423056344f9b6f18c9ff555e66f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..3df4b9c6d54bd928db540aa05084371693ce59a1 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/first-hunk-only.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 188707b2a90f33df3792a692ac881ff91542156f..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -38,10 +38,10 @@ + :return: schema class of given schema (instance or class) + """ + if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return [schema] ++ return schema + if isinstance(schema, marshmallow.Schema): +- return schema +- return marshmallow.class_registry.get_class(schema) ++ return type(schema) ++ return marshmallow.class_registry.get_class(str(schema)) + + + def get_fields( +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__x34b5zjs/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..f1fa6d0c25972a8d3fefc34fdfbda5911a688014 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "82e820c95ad4952b00c96d8b3d3ea568d17169d27b3b7cfaa5e96897d1a4748d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "b8fabf440ce6f49db4b2a261da20d3ef6c0d81ae4014ade7b1f9e88ede0180de", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "46f2ce36b72c2d9498eb77dff347a9e51089ffbd0c4572b33ad172667e02b4ab", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "d7c8e15bd521f54c7d0fc06ac829409aa44d8e92", + "source_completion_sha256": "4ec248133bfdaf9dfe3362ee119f119b3df1d7571844fdbf2bbe2797114d1002", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "cb09f4271c7dd890087858a89bd9b68649790e05a5d6789f97a4eb3ce72f4b3f", + "is_fork": true, + "learner_path": "tasks/f550564e98fb2b6798c4c2aa/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/d7c8e15bd521f54c7d0fc06ac829409aa44d8e92/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "8a5965043afa38d13cda4a04c4c0c606e01f27424da48ce256ce67d77ef05176", + "provenance_path": "tasks/f550564e98fb2b6798c4c2aa/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d7c8e15bd521f54c7d0fc06ac829409aa44d8e92", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ab27a2bbd98dd6bbc24dd008e6a75be6f6384193", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "task_sha256": "2211a7206e96e3e8d9287eda2639c30e01925f7ee0a73b033c42d9183a654029", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ccc7e7dce8365ee721e0cddae4d1643de0ad205d --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/instruction.md @@ -0,0 +1,28 @@ +## build_reference function generates incorrect references for OpenAPI 3.x + +When using `build_reference` with OpenAPI 3.x specifications, the generated references are malformed and cause KeyError exceptions. + +#### Steps/Code to Reproduce + +```python +from apispec.utils import build_reference + +# This should work for OpenAPI 3.0 +ref = build_reference("schema", "Pet", openapi_major_version=3) +print("Generated reference:", ref) +# Expected: {"$ref": "#/components/schemas/Pet"} +# Actual: {"$ref": "#/schemas/teP"} # component name is reversed! +``` + +The issue appears when trying to use any functionality that relies on `build_reference` with OpenAPI 3.x specs. Component names get reversed and the version check logic seems broken. + +#### Environment + +- apispec version: latest +- Python version: 3.x + +The problem manifests when working with OpenAPI 3.x specifications where component references should use the `#/components/` prefix but the current implementation has issues with both the version detection and component name handling. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..fe03b407bb3b06a0868f23a61aeab1c8209366c2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/metadata.json @@ -0,0 +1,736 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "ab27a2bbd98dd6bbc24dd008e6a75be6f6384193", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "d7c8e15bd521f54c7d0fc06ac829409aa44d8e92" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_core.py", + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py", + "tests/test_utils.py", + "tests/test_yaml_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/utils.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 970692, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "cb09f4271c7dd890087858a89bd9b68649790e05a5d6789f97a4eb3ce72f4b3f", + "is_fork": true, + "learner_path": "tasks/f550564e98fb2b6798c4c2aa/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/d7c8e15bd521f54c7d0fc06ac829409aa44d8e92/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "8a5965043afa38d13cda4a04c4c0c606e01f27424da48ce256ce67d77ef05176", + "provenance_path": "tasks/f550564e98fb2b6798c4c2aa/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d7c8e15bd521f54c7d0fc06ac829409aa44d8e92", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ab27a2bbd98dd6bbc24dd008e6a75be6f6384193", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "task_sha256": "2211a7206e96e3e8d9287eda2639c30e01925f7ee0a73b033c42d9183a654029", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..e378d9bdf5dd7948fb4f9ca614be6ab439e3e9a2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "82e820c95ad4952b00c96d8b3d3ea568d17169d27b3b7cfaa5e96897d1a4748d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/d7c8e15bd521f54c7d0fc06ac829409aa44d8e92/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "4ec248133bfdaf9dfe3362ee119f119b3df1d7571844fdbf2bbe2797114d1002", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "008eba91226fdf2a149adb02ed5ec1b0b37999617781f082caf68ca5dd1b2048", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "cb09f4271c7dd890087858a89bd9b68649790e05a5d6789f97a4eb3ce72f4b3f", + "is_fork": true, + "learner_path": "tasks/f550564e98fb2b6798c4c2aa/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/d7c8e15bd521f54c7d0fc06ac829409aa44d8e92/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "8a5965043afa38d13cda4a04c4c0c606e01f27424da48ce256ce67d77ef05176", + "provenance_path": "tasks/f550564e98fb2b6798c4c2aa/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d7c8e15bd521f54c7d0fc06ac829409aa44d8e92", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "ab27a2bbd98dd6bbc24dd008e6a75be6f6384193", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__yu896uyo", + "task_sha256": "2211a7206e96e3e8d9287eda2639c30e01925f7ee0a73b033c42d9183a654029", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..4b5a50d912fa77a6880892d4b12cf0861be48474 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/provided-gold.diff @@ -0,0 +1,77 @@ +diff --git a/src/apispec/utils.py b/src/apispec/utils.py +index 1c424b8ebde1312105e5a5c7acb4d98c0d04e854..0ddb831a3a94d334d28cad8266e4666e5001126b 100644 +--- a/src/apispec/utils.py ++++ b/src/apispec/utils.py +@@ -35,46 +35,27 @@ + """ + return { + "$ref": "#/{}{}/{}".format( +- "components/" if openapi_major_version > 3 else "", +- COMPONENT_SUBSECTIONS[openapi_major_version - 1][component_type], +- component_name[::-1], ++ "components/" if openapi_major_version >= 3 else "", ++ COMPONENT_SUBSECTIONS[openapi_major_version][component_type], ++ component_name, + ) + } + + + # from django.contrib.admindocs.utils +-def trim_docstring(docstring: str) ->str: ++def trim_docstring(docstring: str) -> str: + """Uniformly trims leading/trailing whitespace from docstrings. + + Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation + """ +- if not docstring: +- return '' +- ++ if not docstring or not docstring.strip(): ++ return "" + # Convert tabs to spaces and split into lines + lines = docstring.expandtabs().splitlines() +- +- # Determine minimum indentation (first line doesn't count) +- indent = sys.maxsize +- for line in lines[1:]: +- stripped = line.lstrip() +- if stripped: +- indent = min(indent, len(line) - len(stripped)) +- +- # Remove indentation +- trimmed = [lines[0].strip()] +- if indent < sys.maxsize: +- for line in lines[1:]: +- trimmed.append(line[indent:].rstrip()) +- +- # Strip leading and trailing blank lines +- while trimmed and not trimmed[0]: +- trimmed.pop(0) +- while trimmed and not trimmed[-1]: +- trimmed.pop() +- +- # Return a single string +- return '\n'.join(trimmed) ++ indent = min(len(line) - len(line.lstrip()) for line in lines if line.lstrip()) ++ trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]] ++ return "\n".join(trimmed).strip() ++ + + # from rest_framework.utils.formatting + def dedent(content: str) -> str: +@@ -101,7 +82,6 @@ + + # http://stackoverflow.com/a/8310229 + def deepupdate(original: dict, update: dict) -> dict: +- return update + """Recursively update a dict. + + Subdict's won't be overwritten but also updated. +@@ -110,4 +90,5 @@ + if key not in update: + update[key] = value + elif isinstance(value, dict): +- deepupdate(value, update[key]) +\ No newline at end of file ++ deepupdate(value, update[key]) ++ return update diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a43c4c3a7116b2636568b5171947cc71ddda7819 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/solution/solve.sh @@ -0,0 +1,83 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/utils.py b/src/apispec/utils.py +index 1c424b8ebde1312105e5a5c7acb4d98c0d04e854..0ddb831a3a94d334d28cad8266e4666e5001126b 100644 +--- a/src/apispec/utils.py ++++ b/src/apispec/utils.py +@@ -35,46 +35,27 @@ + """ + return { + "$ref": "#/{}{}/{}".format( +- "components/" if openapi_major_version > 3 else "", +- COMPONENT_SUBSECTIONS[openapi_major_version - 1][component_type], +- component_name[::-1], ++ "components/" if openapi_major_version >= 3 else "", ++ COMPONENT_SUBSECTIONS[openapi_major_version][component_type], ++ component_name, + ) + } + + + # from django.contrib.admindocs.utils +-def trim_docstring(docstring: str) ->str: ++def trim_docstring(docstring: str) -> str: + """Uniformly trims leading/trailing whitespace from docstrings. + + Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation + """ +- if not docstring: +- return '' +- ++ if not docstring or not docstring.strip(): ++ return "" + # Convert tabs to spaces and split into lines + lines = docstring.expandtabs().splitlines() +- +- # Determine minimum indentation (first line doesn't count) +- indent = sys.maxsize +- for line in lines[1:]: +- stripped = line.lstrip() +- if stripped: +- indent = min(indent, len(line) - len(stripped)) +- +- # Remove indentation +- trimmed = [lines[0].strip()] +- if indent < sys.maxsize: +- for line in lines[1:]: +- trimmed.append(line[indent:].rstrip()) +- +- # Strip leading and trailing blank lines +- while trimmed and not trimmed[0]: +- trimmed.pop(0) +- while trimmed and not trimmed[-1]: +- trimmed.pop() +- +- # Return a single string +- return '\n'.join(trimmed) ++ indent = min(len(line) - len(line.lstrip()) for line in lines if line.lstrip()) ++ trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]] ++ return "\n".join(trimmed).strip() ++ + + # from rest_framework.utils.formatting + def dedent(content: str) -> str: +@@ -101,7 +82,6 @@ + + # http://stackoverflow.com/a/8310229 + def deepupdate(original: dict, update: dict) -> dict: +- return update + """Recursively update a dict. + + Subdict's won't be overwritten but also updated. +@@ -110,4 +90,5 @@ + if key not in update: + update[key] = value + elif isinstance(value, dict): +- deepupdate(value, update[key]) +\ No newline at end of file ++ deepupdate(value, update[key]) ++ return update +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3c85adebe72f505e64f39b641fc5dc044e756a9c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:4851b7e3c2284c1633dee7c1f1125e74cd11201eb38f2e87d34c46ac06bd7a67" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..48b5882669996b3d7899a73824bdfb3f9ae03964 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c8e681c8e07d637e27c27aab3748e0fe3c0d3db --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/first-hunk-only.sh @@ -0,0 +1,67 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/utils.py b/src/apispec/utils.py +index 1c424b8ebde1312105e5a5c7acb4d98c0d04e854..0ddb831a3a94d334d28cad8266e4666e5001126b 100644 +--- a/src/apispec/utils.py ++++ b/src/apispec/utils.py +@@ -35,46 +35,27 @@ + """ + return { + "$ref": "#/{}{}/{}".format( +- "components/" if openapi_major_version > 3 else "", +- COMPONENT_SUBSECTIONS[openapi_major_version - 1][component_type], +- component_name[::-1], ++ "components/" if openapi_major_version >= 3 else "", ++ COMPONENT_SUBSECTIONS[openapi_major_version][component_type], ++ component_name, + ) + } + + + # from django.contrib.admindocs.utils +-def trim_docstring(docstring: str) ->str: ++def trim_docstring(docstring: str) -> str: + """Uniformly trims leading/trailing whitespace from docstrings. + + Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation + """ +- if not docstring: +- return '' +- ++ if not docstring or not docstring.strip(): ++ return "" + # Convert tabs to spaces and split into lines + lines = docstring.expandtabs().splitlines() +- +- # Determine minimum indentation (first line doesn't count) +- indent = sys.maxsize +- for line in lines[1:]: +- stripped = line.lstrip() +- if stripped: +- indent = min(indent, len(line) - len(stripped)) +- +- # Remove indentation +- trimmed = [lines[0].strip()] +- if indent < sys.maxsize: +- for line in lines[1:]: +- trimmed.append(line[indent:].rstrip()) +- +- # Strip leading and trailing blank lines +- while trimmed and not trimmed[0]: +- trimmed.pop(0) +- while trimmed and not trimmed[-1]: +- trimmed.pop() +- +- # Return a single string +- return '\n'.join(trimmed) ++ indent = min(len(line) - len(line.lstrip()) for line in lines if line.lstrip()) ++ trimmed = [lines[0].lstrip()] + [line[indent:].rstrip() for line in lines[1:]] ++ return "\n".join(trimmed).strip() ++ + + # from rest_framework.utils.formatting + def dedent(content: str) -> str: +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__yu896uyo/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..870f370e92f3d81a91ab0eb3b8ca2a8c7abf044e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "e72b119b815bd5925e4a70d16dff72f688599654c1da7065979bb9ee3535b961", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "0a0e3f21c669f56b1f4ad74b98266ad55d81dc920fe9ab15407fb9c5afca4b3a", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "f59789d78006cd16193d74918b144015b99f9c68909e7fc6281709fc70551314", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb", + "source_completion_sha256": "1918499f1f703397181b7607d3558565dea64349795bbdc270ec3d45f70915b2", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "7e00404a37a20914a7669b0d789f2dc99bd0aa5083b9475260471b8659e37753", + "is_fork": true, + "learner_path": "tasks/f316f3c1f01a6e60f74604ed/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "1c214df53594973489dc36e55bf07cf2bb179b57dbd70ca75dc00a54bc1a926e", + "provenance_path": "tasks/f316f3c1f01a6e60f74604ed/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a83f5b023e0e80d6cca06385838034bd32bbd04d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "task_sha256": "ad9537793d2b6fd1ddc7330b905c75cef865d902334ceb041b6b4f4bbd2aa995", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..658a94a24158ff0530a8f8eda330dee28daddb27 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/instruction.md @@ -0,0 +1,52 @@ +Incorrect behavior of List fields in OpenAPI parameter conversion + +### Description + +I've noticed a regression in the way List fields are converted to OpenAPI parameters. The current implementation is causing issues with OpenAPI validation and doesn't match the expected behavior. + +### Reproduction + +Here's a minimal example that demonstrates the issue: + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +from marshmallow import fields, Schema + +ma_plugin = MarshmallowPlugin() +spec = APISpec( + title='Test API', + version='1.0.0', + openapi_version='3.0.0', + plugins=(ma_plugin,) +) + +# Create a parameter with a List field +field = fields.List(fields.Str()) +param = ma_plugin.converter._field2parameter(field, name='tags', location='query') + +# This should have specific style and explode values +print(param) +``` + +The output shows incorrect values for `style` and `explode` in OpenAPI 3, and incorrect `collectionFormat` in OpenAPI 2. + +### Expected behavior + +For OpenAPI 3.0: +- List fields in query parameters should have `style: form` and `explode: true` + +For OpenAPI 2.0: +- List fields should have `collectionFormat: multi` + +### Actual behavior + +The current implementation is using different values which causes validation errors when using OpenAPI validators. + +I also noticed that the parameter attribute functions are being added in the wrong order, which might be affecting how field attributes are processed. + +This issue affects both standard List fields and custom List field implementations that extend marshmallow's List field. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..d052142f098be1abcf016aa8fcc5279eb504c7d2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/metadata.json @@ -0,0 +1,746 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "a83f5b023e0e80d6cca06385838034bd32bbd04d", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_ext_marshmallow_field.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/openapi.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1099197, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "7e00404a37a20914a7669b0d789f2dc99bd0aa5083b9475260471b8659e37753", + "is_fork": true, + "learner_path": "tasks/f316f3c1f01a6e60f74604ed/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "1c214df53594973489dc36e55bf07cf2bb179b57dbd70ca75dc00a54bc1a926e", + "provenance_path": "tasks/f316f3c1f01a6e60f74604ed/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a83f5b023e0e80d6cca06385838034bd32bbd04d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "task_sha256": "ad9537793d2b6fd1ddc7330b905c75cef865d902334ceb041b6b4f4bbd2aa995", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..87a56809ab7690fb734f6fa551f1113598bfdee3 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "e72b119b815bd5925e4a70d16dff72f688599654c1da7065979bb9ee3535b961", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "1918499f1f703397181b7607d3558565dea64349795bbdc270ec3d45f70915b2", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "1322c236e5efd5d197a4203174f8d1d653dce55a5f2b44570906137f73dfb6e6", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "7e00404a37a20914a7669b0d789f2dc99bd0aa5083b9475260471b8659e37753", + "is_fork": true, + "learner_path": "tasks/f316f3c1f01a6e60f74604ed/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "1c214df53594973489dc36e55bf07cf2bb179b57dbd70ca75dc00a54bc1a926e", + "provenance_path": "tasks/f316f3c1f01a6e60f74604ed/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "954bc6dcae311b5ad97d9f9ab3cd5fd1dd0e21fb", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a83f5b023e0e80d6cca06385838034bd32bbd04d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_file__z678zgrb", + "task_sha256": "ad9537793d2b6fd1ddc7330b905c75cef865d902334ceb041b6b4f4bbd2aa995", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..a9912467ad734a66de1a8d3a0a291d4da5b38c7e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/provided-gold.diff @@ -0,0 +1,31 @@ +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 9edbe8eb6d20d65074b43034df54798b8206dfa0..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -93,8 +93,8 @@ + field parameter functions in the order they were added. + """ + bound_func = func.__get__(self) +- setattr(self, func.__name__, func) +- self.parameter_attribute_functions.insert(0, bound_func) ++ setattr(self, func.__name__, bound_func) ++ self.parameter_attribute_functions.append(bound_func) + + def resolve_nested_schema(self, schema): + """Return the OpenAPI representation of a marshmallow Schema. +@@ -231,11 +231,11 @@ + """ + ret: dict = {} + if isinstance(field, marshmallow.fields.List): +- if self.openapi_version.major <= 3: +- ret["collectionFormat"] = "csv" ++ if self.openapi_version.major < 3: ++ ret["collectionFormat"] = "multi" + else: +- ret["explode"] = False +- ret["style"] = "matrix" ++ ret["explode"] = True ++ ret["style"] = "form" + return ret + + def schema2jsonschema(self, schema): diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cdfc42ed67acf6b1c0d9f8cedb7804dea7e40632 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/solution/solve.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 9edbe8eb6d20d65074b43034df54798b8206dfa0..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -93,8 +93,8 @@ + field parameter functions in the order they were added. + """ + bound_func = func.__get__(self) +- setattr(self, func.__name__, func) +- self.parameter_attribute_functions.insert(0, bound_func) ++ setattr(self, func.__name__, bound_func) ++ self.parameter_attribute_functions.append(bound_func) + + def resolve_nested_schema(self, schema): + """Return the OpenAPI representation of a marshmallow Schema. +@@ -231,11 +231,11 @@ + """ + ret: dict = {} + if isinstance(field, marshmallow.fields.List): +- if self.openapi_version.major <= 3: +- ret["collectionFormat"] = "csv" ++ if self.openapi_version.major < 3: ++ ret["collectionFormat"] = "multi" + else: +- ret["explode"] = False +- ret["style"] = "matrix" ++ ret["explode"] = True ++ ret["style"] = "form" + return ret + + def schema2jsonschema(self, schema): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dd2b104e74be238a0d36f3b1f93be07b6b686ba1 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:d4b97f5d12ece24637859650f252cfcbf2903201726b96040e1d987bb92d1fd3" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..1f059e6f27fa3576428bb71126364e8b4571b2a8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/expected-panels.json @@ -0,0 +1,575 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::TestField2PropertyPluck::test_many_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..de654464b592ad2d655e4f930e397ca47c94ef13 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/first-hunk-only.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/openapi.py b/src/apispec/ext/marshmallow/openapi.py +index 9edbe8eb6d20d65074b43034df54798b8206dfa0..a114e2652809bd02990b2b7caa31cd6c3d494aea 100644 +--- a/src/apispec/ext/marshmallow/openapi.py ++++ b/src/apispec/ext/marshmallow/openapi.py +@@ -93,8 +93,8 @@ + field parameter functions in the order they were added. + """ + bound_func = func.__get__(self) +- setattr(self, func.__name__, func) +- self.parameter_attribute_functions.insert(0, bound_func) ++ setattr(self, func.__name__, bound_func) ++ self.parameter_attribute_functions.append(bound_func) + + def resolve_nested_schema(self, schema): + """Return the OpenAPI representation of a marshmallow Schema. +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_file__z678zgrb/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/LICENSE.source b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..391528f8068f0c965fdc848a7b3672d77090ea80 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria, Jérôme Lafréchoux, and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/adapter.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..6716cb7f540fd0f58fea0fc3f3e74e612ce9370c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "213839c53a312d83a5569a18303cecdb03befd5a43f54c1af2e7afcf93ea1ac5", + "gold_patch_sha256": "c3b96bb8bd06a77578383235aa359cae48bf617c564ff2723391d58f12c46de5", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "72affa9d8bce11cd3e613f135b3295ea332db4ff3585a4d15ee2964cdfa22f50", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "db3d9112e35f1ea1113905f9cb6739171059c0bb5ab558bb1ae947fea962f912", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__apispec.8b421526.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "93ca7057cbdb165950fc0c945a4b46e618da9a85", + "source_completion_sha256": "e1c57cb8a281ffc452c61304c669785e1941985f4469b730f7bc6899a7a316cb", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_module__07okceme", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8fffe3e2cb980199f02377b531e4d45c6051594c09202d73627742f2dae87944", + "is_fork": true, + "learner_path": "tasks/771f008d8f24aadefe49b1da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/93ca7057cbdb165950fc0c945a4b46e618da9a85/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "5cc704f25d115c3312a875540fe3dcfde8add6aad41d701e2be3a97110771cbb", + "provenance_path": "tasks/771f008d8f24aadefe49b1da/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "93ca7057cbdb165950fc0c945a4b46e618da9a85", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1b2268de8d734b590d88de30ad32af8cff5bc71a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_module__07okceme", + "task_sha256": "872e6f4504fa4f8538d85d9be9bc33f41d40d615073c7e1504e5385dbe883c37", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_module__07okceme", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/apispec" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/dependency-setup.sh b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..f116721ab9c2b5f5a3f8ab55d82049b8cbfa4ae8 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +pip install -e .[dev] +python -m pip install 'marshmallow>=3.10.0,<4.0.0' diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/environment/Dockerfile b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/instruction.md b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..d25f4b8501b7e5b7747c86d61064a0f28c3c4491 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/instruction.md @@ -0,0 +1,55 @@ +Schema resolution broken for class instances when using marshmallow class registry + +#### Description + +When passing a marshmallow Schema class (not instance) to apispec, the schema resolution fails to properly use the class registry, causing issues with schema references and definitions. + +#### Steps/Code to Reproduce + +```python +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin +from marshmallow import Schema, fields + +class PetSchema(Schema): + name = fields.Str() + id = fields.Int() + +# Create spec with marshmallow plugin +spec = APISpec( + title="Test API", + version="1.0.0", + openapi_version="3.0.0", + plugins=[MarshmallowPlugin()] +) + +# This should work but fails to resolve properly +spec.components.schema('Pet', schema=PetSchema) + +# Try to use the schema class in a path definition +spec.path( + path='/pets', + operations={ + 'get': { + 'responses': { + 200: { + 'content': { + 'application/json': { + 'schema': { + 'type': 'array', + 'items': PetSchema + } + } + } + } + } + } + } +) +``` + +The schema resolution doesn't work correctly when passing Schema classes instead of instances, particularly when the class registry is involved. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/metadata.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..cf61e0443796b7e780f66b29093b1bdfc268d530 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/metadata.json @@ -0,0 +1,737 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "PASS_TO_PASS": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "1b2268de8d734b590d88de30ad32af8cff5bc71a", + "healthy": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "learner": "93ca7057cbdb165950fc0c945a4b46e618da9a85" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/Makefile", + "/testbed/docs/api_core.rst", + "/testbed/docs/api_ext.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/license.rst", + "/testbed/docs/make.bat", + "/testbed/docs/quickstart.rst", + "/testbed/docs/special_topics.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/using_plugins.rst", + "/testbed/docs/writing_plugins.rst", + "/testbed/pyproject.toml", + "/testbed/readthedocs.yml", + "/testbed/src/apispec/__init__.py", + "/testbed/src/apispec/core.py", + "/testbed/src/apispec/exceptions.py", + "/testbed/src/apispec/ext/__init__.py", + "/testbed/src/apispec/ext/marshmallow/__init__.py", + "/testbed/src/apispec/ext/marshmallow/common.py", + "/testbed/src/apispec/ext/marshmallow/field_converter.py", + "/testbed/src/apispec/ext/marshmallow/openapi.py", + "/testbed/src/apispec/ext/marshmallow/schema_resolver.py", + "/testbed/src/apispec/plugin.py", + "/testbed/src/apispec/py.typed", + "/testbed/src/apispec/utils.py", + "/testbed/src/apispec/yaml_utils.py", + "/testbed/tests/__init__.py", + "/testbed/tests/conftest.py", + "/testbed/tests/schemas.py", + "/testbed/tests/test_core.py", + "/testbed/tests/test_ext_marshmallow_common.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_yaml_utils.py", + "/testbed/tests/utils.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Apispec8b421526", + "profile_lines": [ + 127, + 131 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "upstream_repo": "marshmallow-code/apispec" + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "private_test_paths": [ + "tests/test_ext_marshmallow.py", + "tests/test_ext_marshmallow_field.py", + "tests/test_ext_marshmallow_openapi.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/apispec/ext/marshmallow/common.py", + "src/apispec/ext/marshmallow/field_converter.py" + ], + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_stages_bytes": 1023943, + "task_id": "marshmallow-code__apispec.8b421526.combine_module__07okceme", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/apispec" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_module__07okceme", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8fffe3e2cb980199f02377b531e4d45c6051594c09202d73627742f2dae87944", + "is_fork": true, + "learner_path": "tasks/771f008d8f24aadefe49b1da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/93ca7057cbdb165950fc0c945a4b46e618da9a85/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "5cc704f25d115c3312a875540fe3dcfde8add6aad41d701e2be3a97110771cbb", + "provenance_path": "tasks/771f008d8f24aadefe49b1da/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "93ca7057cbdb165950fc0c945a4b46e618da9a85", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1b2268de8d734b590d88de30ad32af8cff5bc71a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_module__07okceme", + "task_sha256": "872e6f4504fa4f8538d85d9be9bc33f41d40d615073c7e1504e5385dbe883c37", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provenance.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..93438a6e90ae5cc9279ce9c5bda63a45ee1dd590 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "c3b96bb8bd06a77578383235aa359cae48bf617c564ff2723391d58f12c46de5", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/93ca7057cbdb165950fc0c945a4b46e618da9a85/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "e1c57cb8a281ffc452c61304c669785e1941985f4469b730f7bc6899a7a316cb", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "b9d926d2a16397949a7868ca870febd0ccee0bd99a86afc33fb06cdda0ad12af", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__apispec.8b421526.combine_module__07okceme", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "d8b6184dbd502b9824e83fe8b294552f31ee754e", + "instruction_sha256": "8fffe3e2cb980199f02377b531e4d45c6051594c09202d73627742f2dae87944", + "is_fork": true, + "learner_path": "tasks/771f008d8f24aadefe49b1da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/apispec/8b421526ea1015046de42599dd93da6a3473fe44/LICENSE", + "reviewed": true, + "sha256": "f345555ff39d6b573342781a6346a5202a8f14bce424fee41f910c6c5379cc7d", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__apispec.8b421526/93ca7057cbdb165950fc0c945a4b46e618da9a85/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "8b421526ea1015046de42599dd93da6a3473fe44", + "patch_sha256": "5cc704f25d115c3312a875540fe3dcfde8add6aad41d701e2be3a97110771cbb", + "provenance_path": "tasks/771f008d8f24aadefe49b1da/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__apispec.8b421526", + "marshmallow-code/apispec" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "93ca7057cbdb165950fc0c945a4b46e618da9a85", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1b2268de8d734b590d88de30ad32af8cff5bc71a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__apispec.8b421526", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__apispec.8b421526.combine_module__07okceme", + "task_sha256": "872e6f4504fa4f8538d85d9be9bc33f41d40d615073c7e1504e5385dbe883c37", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/apispec", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "800ba7da08ca9ff402906f2c3f0f85c4f500c385020e3e6b6d0a029e65c0654e" +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provided-gold.diff b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..3d8a2c21a998d13d9341320f97c7e267a32764aa --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/provided-gold.diff @@ -0,0 +1,34 @@ +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 3aa1b1f1bd545fc148d9a7fbdf690c2ac93e7e25..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py +index 8b6af4f0ee89979b6e5c6c8605fbfe822ff9a99b..9016e5f53f2609f75bf128a0e68b1d5a2c56b8a3 100644 +--- a/src/apispec/ext/marshmallow/field_converter.py ++++ b/src/apispec/ext/marshmallow/field_converter.py +@@ -272,8 +272,8 @@ + :param Field field: A marshmallow field. + :rtype: dict + """ +- attributes = {"readOnly": False} +- if not field.dump_only: ++ attributes = {} ++ if field.dump_only: + attributes["readOnly"] = True + return attributes + diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/solution/solve.sh b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e806c7149b9ab14c5b03d5a404729a7ffbf557da --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/solution/solve.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 3aa1b1f1bd545fc148d9a7fbdf690c2ac93e7e25..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py +index 8b6af4f0ee89979b6e5c6c8605fbfe822ff9a99b..9016e5f53f2609f75bf128a0e68b1d5a2c56b8a3 100644 +--- a/src/apispec/ext/marshmallow/field_converter.py ++++ b/src/apispec/ext/marshmallow/field_converter.py +@@ -272,8 +272,8 @@ + :param Field field: A marshmallow field. + :rtype: dict + """ +- attributes = {"readOnly": False} +- if not field.dump_only: ++ attributes = {} ++ if field.dump_only: + attributes["readOnly"] = True + return attributes + +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/task.toml b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..aa5a25f291fa2b5a6c252bcc4b2f2e4f89bdd26d --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:6adbd6b0d5b4be44309781a56d5172e434b7ecd93083a670ca449984d8db8a33" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/check_pytest.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc3977e41867a5171bd0ba40de1f1c904875c55e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/check_pytest.py @@ -0,0 +1,91 @@ +"""Distinguish real pytest failures from missing/setup/verifier evidence.""" + +import argparse +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + + +def matches(case, target): + parts = target.split("::") + module = parts[0].removesuffix(".py").replace("/", ".") + classname = case.get("classname", "") + name = case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def assess(root, expected, native_exit): + all_cases = [] + actual_failure = False + for group in ("pass-to-pass", "fail-to-pass"): + path = Path(root) / (group + ".xml") + if not path.exists(): + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + raw = path.read_bytes() + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(c.get("classname"), c.get("name")) for c in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + targets = expected[group] + if any(not any(matches(case, t) for t in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [c for c in cases if c.find("failure") is not None] + if any( + c.find("error") is not None or c.find("skipped") is not None for c in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, t) for case in cases) for t in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + for group in ("pass-to-pass", "fail-to-pass"): + if not (Path(root) / (group + ".xml")).is_file(): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("--root", required=True) + p.add_argument("--expected", required=True) + p.add_argument("--native-exit", type=int, required=True) + a = p.parse_args() + result = assess(a.root, json.loads(Path(a.expected).read_text()), a.native_exit) + reward = Path(a.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(a.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/expected-panels.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..a62fa20214228ad1f7ece38fc4d50e5b015bc3fc --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/expected-panels.json @@ -0,0 +1,565 @@ +{ + "fail-to-pass": [ + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instances_with_different_modifiers_added[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_instance_with_different_modifers_custom_resolver", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[PetSchema-3.0.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[2.0]", + "tests/test_ext_marshmallow.py::TestCustomField::test_can_use_custom_field_decorator[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_expand_parameters_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v2", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_allof_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[oneOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[anyOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_oneof_anyof_allof_v3[allOf-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_resolver_not_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[tests.schemas.PetSchema]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_array_uses_ref_if_available_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v2[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_partially_v3[3.0.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[2.0]", + "tests/test_ext_marshmallow.py::TestCircularReference::test_circular_referencing_schemas[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_single[3.0.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[2.0]", + "tests/test_ext_marshmallow.py::TestSelfReference::test_self_referencing_field_many[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_values_resolve_to_additional_properties[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_empty_values_field[3.0.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestDictValues::test_dict_with_nested[3.0.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[2.0]", + "tests/test_ext_marshmallow.py::TestList::test_list_with_nested[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_nullable_with_metadata[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_pluck[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec_metadatas[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many_spec[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_ref[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[2.0]", + "tests/test_ext_marshmallow_field.py::test_nested_field_with_property[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_iso[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_rfc[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_timestamp_ms[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime2property_custom_format_missing_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_with_non_string_metadata_keys[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_fields_with_adhoc_changes[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v2", + "tests/test_ext_marshmallow_openapi.py::test_openapi_tools_validate_v3" + ], + "pass-to-pass": [ + "tests/test_core.py::TestAPISpecInit::test_raises_wrong_apispec_version", + "tests/test_core.py::TestMetadata::test_openapi_metadata[2.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata[3.0.0]", + "tests/test_core.py::TestMetadata::test_openapi_metadata_merge_v3[3.0.0]", + "tests/test_core.py::TestTags::test_tag[2.0]", + "tests/test_core.py::TestTags::test_tag[3.0.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[2.0]", + "tests/test_core.py::TestTags::test_tag_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema[2.0]", + "tests/test_core.py::TestComponents::test_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_schema_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_description[2.0]", + "tests/test_core.py::TestComponents::test_schema_description[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[2.0]", + "tests/test_core.py::TestComponents::test_schema_stores_enum[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[2.0]", + "tests/test_core.py::TestComponents::test_schema_discriminator[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_schema_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_response[2.0]", + "tests/test_core.py::TestComponents::test_response[3.0.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_response_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_response_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter[2.0]", + "tests/test_core.py::TestComponents::test_parameter[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_parameter_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_parameter_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_header[3.0.0]", + "tests/test_core.py::TestComponents::test_header_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_header_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_example[3.0.0]", + "tests/test_core.py::TestComponents::test_example_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_example_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_is_chainable[3.0.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[2.0]", + "tests/test_core.py::TestComponents::test_security_scheme_duplicate_name[3.0.0]", + "tests/test_core.py::TestComponents::test_to_yaml[2.0]", + "tests/test_core.py::TestComponents::test_to_yaml[3.0.0]", + "tests/test_core.py::TestComponents::test_components_can_be_accessed_by_plugin_in_init_spec", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_response_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_parameter_schemas_v3[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_header_examples[3.0.0]", + "tests/test_core.py::TestComponents::test_components_resolve_refs_in_header_schema[3.0.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[2.0]", + "tests/test_core.py::TestComponents::test_schema_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_response_lazy[2.0]", + "tests/test_core.py::TestComponents::test_response_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[2.0]", + "tests/test_core.py::TestComponents::test_parameter_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_header_lazy[3.0.0]", + "tests/test_core.py::TestComponents::test_example_lazy[3.0.0]", + "tests/test_core.py::TestPath::test_path[2.0]", + "tests/test_core.py::TestPath::test_path[3.0.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_paths_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[2.0]", + "tests/test_core.py::TestPath::test_path_is_chainable[3.0.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[2.0]", + "tests/test_core.py::TestPath::test_path_methods_maintain_order[3.0.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[2.0]", + "tests/test_core.py::TestPath::test_path_merges_paths[3.0.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[2.0]", + "tests/test_core.py::TestPath::test_path_called_twice_with_same_operations_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[2.0]", + "tests/test_core.py::TestPath::test_path_ensures_path_parameters_required[3.0.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[2.0]", + "tests/test_core.py::TestPath::test_path_with_no_path_raises_error[3.0.0]", + "tests/test_core.py::TestPath::test_path_summary_description[2.0]", + "tests/test_core.py::TestPath::test_path_summary_description[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_parameter[3.0.0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[2.0-parameters1]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters0]", + "tests/test_core.py::TestPath::test_path_invalid_parameter[3.0.0-parameters1]", + "tests/test_core.py::TestPath::test_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameters[2.0]", + "tests/test_core.py::TestPath::test_global_parameters[3.0.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[2.0]", + "tests/test_core.py::TestPath::test_global_parameter_duplicate[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[2.0]", + "tests/test_core.py::TestPath::test_path_resolves_response[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_HTTPStatus_code[3.0.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[2.0]", + "tests/test_core.py::TestPath::test_path_response_with_status_code_range[3.0.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[2.0]", + "tests/test_core.py::TestPath::test_path_check_invalid_http_method[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_callbacks[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_header_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_response_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_request_body_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_examples[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_parameter_schemas[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_response_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[2.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_parameter_schema[3.0.0]", + "tests/test_core.py::TestPath::test_path_resolve_refs_in_request_body_schema[3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_schema_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_parameter_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_response_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_header_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[True-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-2.0]", + "tests/test_core.py::TestPlugins::test_plugin_path_helper_is_used[False-3.0.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[2.0]", + "tests/test_core.py::TestPlugins::test_plugin_operation_helper_is_used[3.0.0]", + "tests/test_core.py::TestPluginsOrder::test_plugins_order", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_can_use_schema_as_definition[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_helper_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[AnalysisWithListSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_in_list[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_schema_dict_auto_reference_return_none[schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-AnalysisSchema]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_warning_when_schema_added_twice[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[2.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_schema_with_clashing_names[3.0.0]", + "tests/test_ext_marshmallow.py::TestDefinitionHelper::test_resolve_nested_schema_many_true_resolver_return_none", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentParameterHelper::test_can_use_schema_in_parameter_with_content[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[2.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_can_use_schema_in_response_header[3.0.0-schema1]", + "tests/test_ext_marshmallow.py::TestComponentResponseHelper::test_content_without_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestComponentHeaderHelper::test_can_use_schema_in_header[schema1-3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v2[2.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_callback_schema_v3[3.0.0-pet_schema2]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v2[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_name_resolver_returns_none_v3[pet_schema1]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_parameter_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_response_reference[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2json[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_schema_global_state_untouched_2parameters[3.0.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[2.0]", + "tests/test_ext_marshmallow.py::TestOperationHelper::test_resolve_schema_dict_ref_as_string[3.0.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[2.0]", + "tests/test_ext_marshmallow.py::TestOrderedSchema::test_ordered_schema[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props[3.0.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[2.0]", + "tests/test_ext_marshmallow.py::TestFieldWithCustomProps::test_field_with_custom_props_passed_as_snake_case[3.0.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[2.0]", + "tests/test_ext_marshmallow.py::TestSchemaWithDefaultValues::test_schema_with_default_values[3.0.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[2.0]", + "tests/test_ext_marshmallow.py::TestTimeDelta::test_timedelta_x_unit[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_raise_if_schema_class_passed", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[list]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_same_schemas_instances_unhashable_modifiers_equal[set]", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_different_schemas_not_equal", + "tests/test_ext_marshmallow_common.py::TestMakeSchemaKey::test_instances_with_different_modifiers_not_equal", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[2.0]", + "tests/test_ext_marshmallow_common.py::TestUniqueName::test_unique_name[3.0.0]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[tuple-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-tuple]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_get_fields_meta_exclude_dump_only_as_list_and_tuple[list-list]", + "tests/test_ext_marshmallow_common.py::TestGetFields::test_schema_with_field_named_fields", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2choices_preserving_order[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[2.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Integer-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Float-number]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-String-string1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean0]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Boolean-boolean1]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-UUID-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-DateTime-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Date-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Time-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-TimeDelta-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Email-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-Url-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IP-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv4-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-IPv6-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomStringField-string]", + "tests/test_ext_marshmallow_field.py::test_field2property_type[3.0.0-CustomIntegerField-integer]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[2.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-List]", + "tests/test_ext_marshmallow_field.py::test_formatted_field_translates_to_array[3.0.0-CustomList]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[2.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-UUID-uuid]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-DateTime-date-time]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Date-date]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Email-email]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-Url-url]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IP-ip]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv4-ipv4]", + "tests/test_ext_marshmallow_field.py::test_field2property_formats[3.0.0-IPv6-ipv6]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_description[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_boolean_field_with_false_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_datetime_field_with_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_default_callable[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_default_and_load_default[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_nullable_choices_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_equal[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_only_allows_valid_properties_in_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_choices_multiple[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_additional_metadata[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_allow_none[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Field-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_field_with_no_type[Raw-3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_load_only[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_no_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Float]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_string_type[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_with_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_type_list_without_number[3.1.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_range_datetime_type[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_str_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_pattern_obj_regex[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_no_pattern[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[2.0]", + "tests/test_ext_marshmallow_field.py::test_field_with_multiple_patterns[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[2.0]", + "tests/test_ext_marshmallow_field.py::test_enum_symbol_field[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[2.0-True]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-Integer]", + "tests/test_ext_marshmallow_field.py::test_enum_value_field[3.0.0-True]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[2.0]", + "tests/test_ext_marshmallow_field.py::test_nullable_enum_returns_only_one_none[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[2.0]", + "tests/test_ext_marshmallow_field.py::test_field2property_nested_many[3.0.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_field.py::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_load_default_load[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_default_location_mapping_if_schema_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowFieldToOpenAPI::test_fields_with_dump_only[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_with_explicit_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema2jsonschema_override_name[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_no_required_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_title_and_description_may_be_added[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_excluded_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_disallow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_allow[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_unknown_values_ignore[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_only_explicitly_declared_fields_are_translated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_observed_field_name_for_required_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[2.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-True]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_schema_instance_inspection[3.0.0-False]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToModelDefinition::test_raises_error_if_no_declared_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_custom_properties_for_custom_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_required[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_deprecated[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_partial_list[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[2.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-List]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_field_list[3.0.0-CustomList]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_with_dump_only[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_body_many[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_schema_query_instance_many_should_raise_exception[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_fields_query[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestMarshmallowSchemaToParameters::test_raises_error_if_not_a_schema[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[2.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-only]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_nested_fields_only_exclude[3.0.0-exclude]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[2.0]", + "tests/test_ext_marshmallow_openapi.py::TestNesting::test_schema2jsonschema_with_plucked_field[3.0.0]", + "tests/test_ext_marshmallow_openapi.py::test_openapi_converter_openapi_version_types", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[2.0-date_range-properties9]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range-properties0]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-range_no_upper-properties1]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_ranges-properties2]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-list_length-properties3]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_list_length-properties4]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-string_length-properties5]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-custom_field_length-properties6]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-multiple_lengths-properties7]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-equal_length-properties8]", + "tests/test_ext_marshmallow_openapi.py::TestFieldValidation::test_properties[3.0.0-date_range-properties9]", + "tests/test_utils.py::test_build_reference", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_yaml_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[None]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[]", + "tests/test_yaml_utils.py::test_load_operations_from_docstring_empty_docstring[---]", + "tests/test_yaml_utils.py::test_dict_to_yaml_unicode", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_are_not_sorted_by_default", + "tests/test_yaml_utils.py::test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs" + ] +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/grade.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/panel-config.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..162f7605dc915cdd69684d7a98567f66f0c4c786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "pip install -e .[dev]" + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install 'marshmallow>=3.10.0,<4.0.0'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4", + "tox.ini": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/test.sh b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted-inventory.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..206cfb06c7fc3f346db5ea874cddd22c7deb2c08 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted-inventory.json @@ -0,0 +1,72 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2488, + "mode": 420, + "sha256": "3ec695df908d5fe31fd787988101bab7398e8867750ed2e9912506c5a738f0a4" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/conftest.py": { + "bytes": 810, + "mode": 420, + "sha256": "0009b46d9e729e75bd002d1e0864afaca1f96a6953ce60f8389410bebd0787e2" + }, + "tests/schemas.py": { + "bytes": 2130, + "mode": 420, + "sha256": "64084646e19c70bf1170dd6639bdd6800dd92a3983074ed2841fae60fbaaec61" + }, + "tests/test_core.py": { + "bytes": 51766, + "mode": 420, + "sha256": "18ca6c50d1894f5b4fc3d981412341ceed3cc1401bca7ab5ec0c8688b2c67ff3" + }, + "tests/test_ext_marshmallow.py": { + "bytes": 52950, + "mode": 420, + "sha256": "12f40adf8f18db5073d9f0b692562c528eebc008307e982149da48c7fb600cf5" + }, + "tests/test_ext_marshmallow_common.py": { + "bytes": 3236, + "mode": 420, + "sha256": "e17249f21422b2fa79f74f51898f242cb1e9786d0ba6df58bc3086d928d51d79" + }, + "tests/test_ext_marshmallow_field.py": { + "bytes": 22438, + "mode": 420, + "sha256": "39223a47f90ca40e515a7e34ac8806087b3e0ba2968f6832b0a4a77c8c7226b1" + }, + "tests/test_ext_marshmallow_openapi.py": { + "bytes": 24310, + "mode": 420, + "sha256": "d4edc2675840f8cc7ba0dda6169e2ab3e5c59907e20ae26576d4860828cb9e6b" + }, + "tests/test_utils.py": { + "bytes": 918, + "mode": 420, + "sha256": "54f00d286b489440bc17cbbb162fcd53c7aedd8f96dea8d5064f44f70c026810" + }, + "tests/test_yaml_utils.py": { + "bytes": 1285, + "mode": 420, + "sha256": "4a4af4dc1f013207b65093d25ac67809409c1ec7f63f03122a27bf9e1c873003" + }, + "tests/utils.py": { + "bytes": 1806, + "mode": 420, + "sha256": "a0de7ce4c28047b674ffe7d5ff4cf2b9d97a07378b529c1f058a7099838ea000" + }, + "tox.ini": { + "bytes": 778, + "mode": 420, + "sha256": "ef999fed2b6069e442fd54748aac1250090141f2a9dbb1b69502632c3fedc2f7" + } + } +} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/pyproject.toml b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..885faf9142abc84ec2659ac8a46305248b1623cd --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/pyproject.toml @@ -0,0 +1,97 @@ +[project] +name = "apispec" +version = "6.8.1" +description = "A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +keywords = [ + "apispec", + "swagger", + "openapi", + "specification", + "oas", + "documentation", + "spec", + "rest", + "api", +] +requires-python = ">=3.9" +dependencies = ["packaging>=21.3"] + +[project.urls] +Changelog = "https://apispec.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/apispec/issues" +Source = "https://github.com/marshmallow-code/apispec" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-apispec?utm_source=pypi-apispec&utm_medium=pypi" + +[project.optional-dependencies] +yaml = ["PyYAML>=3.10"] +marshmallow = ["marshmallow>=3.18.0"] +docs = [ + "apispec[marshmallow]", + "pyyaml==6.0.2", + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "sphinx-rtd-theme==3.0.2", +] +tests = ["apispec[yaml,marshmallow]", "openapi-spec-validator==0.7.1", "pytest"] +dev = ["apispec[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..879e66024409ed5d58ab53a0b9ac20db46fe3786 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/conftest.py @@ -0,0 +1,35 @@ +from collections import namedtuple + +import pytest + +from apispec import APISpec +from apispec.ext.marshmallow import MarshmallowPlugin + + +def make_spec(openapi_version): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Validation", + version="0.1", + openapi_version=openapi_version, + plugins=(ma_plugin,), + ) + return namedtuple("Spec", ("spec", "marshmallow_plugin", "openapi"))( + spec, ma_plugin, ma_plugin.converter + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec_fixture(request): + return make_spec(request.param) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + return make_spec(request.param).spec + + +@pytest.fixture(params=("2.0", "3.0.0")) +def openapi(request): + spec = make_spec(request.param) + return spec.openapi diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/schemas.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8d44d26e66d3a7220e598bf1102d4ebada2a28c6 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/schemas.py @@ -0,0 +1,85 @@ +from marshmallow import Schema, fields + + +class PetSchema(Schema): + description = dict(id="Pet id", name="Pet name", password="Password") + id = fields.Int(dump_only=True, metadata={"description": description["id"]}) + name = fields.Str( + required=True, + metadata={ + "description": description["name"], + "deprecated": False, + "allowEmptyValue": False, + }, + ) + password = fields.Str( + load_only=True, metadata={"description": description["password"]} + ) + + +class SampleSchema(Schema): + runs = fields.Nested("RunSchema", many=True) + + count = fields.Int() + + +class RunSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisSchema(Schema): + sample = fields.Nested(SampleSchema) + + +class AnalysisWithListSchema(Schema): + samples = fields.List(fields.Nested(SampleSchema)) + + +class PatternedObjectSchema(Schema): + count = fields.Int(dump_only=True, metadata={"x-count": 1}) + count2 = fields.Int(dump_only=True, metadata={"x_count2": 2}) + + +class SelfReferencingSchema(Schema): + id = fields.Int() + single = fields.Nested(lambda: SelfReferencingSchema()) + multiple = fields.Nested(lambda: SelfReferencingSchema(many=True)) + + +class OrderedSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + + +class DefaultValuesSchema(Schema): + number_auto_default = fields.Int(load_default=12) + number_manual_default = fields.Int(load_default=12, metadata={"default": 42}) + string_callable_default = fields.Str(load_default=lambda: "Callable") + string_manual_default = fields.Str( + load_default=lambda: "Callable", metadata={"default": "Manual"} + ) + numbers = fields.List(fields.Int, load_default=list) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class CustomList(fields.List): + pass + + +class CustomStringField(fields.String): + pass + + +class CustomIntegerField(fields.Integer): + pass diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_core.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_core.py new file mode 100644 index 0000000000000000000000000000000000000000..e18c9eb30c7c6e92d31b2ae0109e2bd4ec6c8d59 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_core.py @@ -0,0 +1,1269 @@ +import copy +from http import HTTPStatus + +import pytest +import yaml + +from apispec import APISpec, BasePlugin +from apispec.exceptions import ( + APISpecError, + DuplicateComponentNameError, + DuplicateParameterError, + InvalidParameterError, +) + +from .utils import ( + build_ref, + get_examples, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, + get_security_schemes, +) + +description = "This is a sample Petstore server. You can find out more " +'about Swagger at http://swagger.wordnik.com ' +"or on irc.freenode.net, #swagger. For this sample, you can use the api " +'key "special-key" to test the authorization filters' + + +class RefsSchemaTestMixin: + REFS_SCHEMA = { + "properties": { + "nested": "NestedSchema", + "deep_nested": {"properties": {"nested": "NestedSchema"}}, + "nested_list": {"items": "DeepNestedSchema"}, + "deep_nested_list": { + "items": {"properties": {"nested": "DeepNestedSchema"}} + }, + "allof": { + "allOf": [ + "AllOfSchema", + {"properties": {"nested": "AllOfSchema"}}, + ] + }, + "oneof": { + "oneOf": [ + "OneOfSchema", + {"properties": {"nested": "OneOfSchema"}}, + ] + }, + "anyof": { + "anyOf": [ + "AnyOfSchema", + {"properties": {"nested": "AnyOfSchema"}}, + ] + }, + "not": "NotSchema", + "deep_not": {"properties": {"nested": "DeepNotSchema"}}, + } + } + + @staticmethod + def assert_schema_refs(spec, schema): + props = schema["properties"] + assert props["nested"] == build_ref(spec, "schema", "NestedSchema") + assert props["deep_nested"]["properties"]["nested"] == build_ref( + spec, "schema", "NestedSchema" + ) + assert props["nested_list"]["items"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["deep_nested_list"]["items"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNestedSchema" + ) + assert props["allof"]["allOf"][0] == build_ref(spec, "schema", "AllOfSchema") + assert props["allof"]["allOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AllOfSchema" + ) + assert props["oneof"]["oneOf"][0] == build_ref(spec, "schema", "OneOfSchema") + assert props["oneof"]["oneOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "OneOfSchema" + ) + assert props["anyof"]["anyOf"][0] == build_ref(spec, "schema", "AnyOfSchema") + assert props["anyof"]["anyOf"][1]["properties"]["nested"] == build_ref( + spec, "schema", "AnyOfSchema" + ) + assert props["not"] == build_ref(spec, "schema", "NotSchema") + assert props["deep_not"]["properties"]["nested"] == build_ref( + spec, "schema", "DeepNotSchema" + ) + + +@pytest.fixture(params=("2.0", "3.0.0")) +def spec(request): + openapi_version = request.param + if openapi_version == "2.0": + security_kwargs = {"security": [{"apiKey": []}]} + else: + security_kwargs = { + "components": { + "securitySchemes": { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + }, + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "ok": { + "type": "boolean", + "description": "status indicator", + "example": False, + } + }, + "required": ["ok"], + } + }, + } + } + return APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + info={"description": description}, + **security_kwargs, + ) + + +class TestAPISpecInit: + def test_raises_wrong_apispec_version(self): + message = "Not a valid OpenAPI version number:" + with pytest.raises(APISpecError, match=message): + APISpec( + "Swagger Petstore", + version="1.0.0", + openapi_version="4.0", # 4.0 is not supported + info={"description": description}, + security=[{"apiKey": []}], + ) + + +class TestMetadata: + def test_openapi_metadata(self, spec): + metadata = spec.to_dict() + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + if spec.openapi_version.major < 3: + assert metadata["swagger"] == str(spec.openapi_version) + assert metadata["security"] == [{"apiKey": []}] + else: + assert metadata["openapi"] == str(spec.openapi_version) + security_schemes = { + "bearerAuth": dict(type="http", scheme="bearer", bearerFormat="JWT") + } + assert metadata["components"]["securitySchemes"] == security_schemes + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["info"]["title"] == "Swagger Petstore" + assert metadata["info"]["version"] == "1.0.0" + assert metadata["info"]["description"] == description + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_openapi_metadata_merge_v3(self, spec): + properties = { + "ok": { + "type": "boolean", + "description": "property description", + "example": True, + } + } + spec.components.schema( + "definition", {"properties": properties, "description": "description"} + ) + metadata = spec.to_dict() + assert metadata["components"]["schemas"].get("ErrorResponse", False) + assert metadata["components"]["schemas"].get("definition", False) + + +class TestTags: + tag = { + "name": "MyTag", + "description": "This tag gathers all API endpoints which are mine.", + } + + def test_tag(self, spec): + spec.tag(self.tag) + tags_json = spec.to_dict()["tags"] + assert self.tag in tags_json + + def test_tag_is_chainable(self, spec): + spec.tag({"name": "tag1"}).tag({"name": "tag2"}) + assert spec.to_dict()["tags"] == [{"name": "tag1"}, {"name": "tag2"}] + + +class TestComponents(RefsSchemaTestMixin): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + def test_schema(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert schemas["Pet"]["properties"] == self.properties + + def test_schema_is_chainable(self, spec): + spec.components.schema("Pet", {"properties": {}}).schema( + "Plant", {"properties": {}} + ) + schemas = get_schemas(spec) + assert "Pet" in schemas + assert "Plant" in schemas + + def test_schema_description(self, spec): + model_description = "An animal which lives with humans." + spec.components.schema( + "Pet", {"properties": self.properties, "description": model_description} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["description"] == model_description + + def test_schema_stores_enum(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", {"properties": self.properties, "enum": enum}) + schemas = get_schemas(spec) + assert schemas["Pet"]["enum"] == enum + + def test_schema_discriminator(self, spec): + spec.components.schema( + "Pet", {"properties": self.properties, "discriminator": "name"} + ) + schemas = get_schemas(spec) + assert schemas["Pet"]["discriminator"] == "name" + + def test_schema_duplicate_name(self, spec): + spec.components.schema("Pet", {"properties": self.properties}) + with pytest.raises( + DuplicateComponentNameError, + match='Another schema with name "Pet" is already registered.', + ): + spec.components.schema("Pet", properties=self.properties) + + def test_response(self, spec): + response = {"description": "Pet not found"} + spec.components.response("NotFound", response) + responses = get_responses(spec) + assert responses["NotFound"] == response + + def test_response_is_chainable(self, spec): + spec.components.response("resp1").response("resp2") + responses = get_responses(spec) + assert "resp1" in responses + assert "resp2" in responses + + def test_response_duplicate_name(self, spec): + spec.components.response("test_response") + with pytest.raises( + DuplicateComponentNameError, + match='Another response with name "test_response" is already registered.', + ): + spec.components.response("test_response") + + def test_parameter(self, spec): + # Note: this is an OpenAPI v2 parameter header + # but is does the job for the test even for OpenAPI v3 + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("PetId", "path", parameter) + params = get_parameters(spec) + assert params["PetId"] == { + "format": "int64", + "type": "integer", + "in": "path", + "name": "PetId", + "required": True, + } + + def test_parameter_is_chainable(self, spec): + spec.components.parameter("param1", "path").parameter("param2", "path") + params = get_parameters(spec) + assert "param1" in params + assert "param2" in params + + def test_parameter_duplicate_name(self, spec): + spec.components.parameter("test_parameter", "path") + with pytest.raises( + DuplicateComponentNameError, + match='Another parameter with name "test_parameter" is already registered.', + ): + spec.components.parameter("test_parameter", "path") + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("test_header", header.copy()) + headers = get_headers(spec) + assert headers["test_header"] == header + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_is_chainable(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("header1", header).header("header2", header) + headers = get_headers(spec) + assert "header1" in headers + assert "header2" in headers + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_duplicate_name(self, spec): + spec.components.header("test_header", {"schema": {"type": "string"}}) + with pytest.raises( + DuplicateComponentNameError, + match='Another header with name "test_header" is already registered.', + ): + spec.components.header("test_header", {"schema": {"type": "integer"}}) + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example(self, spec): + spec.components.example("test_example", {"value": {"a": "b"}}) + examples = get_examples(spec) + assert examples["test_example"]["value"] == {"a": "b"} + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_is_chainable(self, spec): + spec.components.example("test_example_1", {}).example("test_example_2", {}) + examples = get_examples(spec) + assert "test_example_1" in examples + assert "test_example_2" in examples + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_duplicate_name(self, spec): + spec.components.example("test_example", {}) + with pytest.raises( + DuplicateComponentNameError, + match='Another example with name "test_example" is already registered.', + ): + spec.components.example("test_example", {}) + + def test_security_scheme(self, spec): + sec_scheme = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme) + assert get_security_schemes(spec)["ApiKeyAuth"] == sec_scheme + + def test_security_scheme_is_chainable(self, spec): + spec.components.security_scheme("sec_1", {}).security_scheme("sec_2", {}) + security_schemes = get_security_schemes(spec) + assert "sec_1" in security_schemes + assert "sec_2" in security_schemes + + def test_security_scheme_duplicate_name(self, spec): + sec_scheme_1 = {"type": "apiKey", "in": "header", "name": "X-API-Key"} + sec_scheme_2 = {"type": "apiKey", "in": "header", "name": "X-API-Key-2"} + spec.components.security_scheme("ApiKeyAuth", sec_scheme_1) + with pytest.raises( + DuplicateComponentNameError, + match='Another security scheme with name "ApiKeyAuth" is already registered.', + ): + spec.components.security_scheme("ApiKeyAuth", sec_scheme_2) + + def test_to_yaml(self, spec): + enum = ["name", "photoUrls"] + spec.components.schema("Pet", properties=self.properties, enum=enum) + assert spec.to_dict() == yaml.safe_load(spec.to_yaml()) + + def test_components_can_be_accessed_by_plugin_in_init_spec(self): + class TestPlugin(BasePlugin): + def init_spec(self, spec): + spec.components.schema( + "TestSchema", + {"properties": {"key": {"type": "string"}}, "type": "object"}, + ) + + spec = APISpec( + "Test API", version="0.0.1", openapi_version="2.0", plugins=[TestPlugin()] + ) + assert get_schemas(spec) == { + "TestSchema": {"properties": {"key": {"type": "string"}}, "type": "object"} + } + + def test_components_resolve_refs_in_schema(self, spec): + spec.components.schema("refs_schema", copy.deepcopy(self.REFS_SCHEMA)) + self.assert_schema_refs(spec, get_schemas(spec)["refs_schema"]) + + def test_components_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.components.response("Response", schema) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_refs_in_response_schema(self, spec): + schema = copy.deepcopy(self.REFS_SCHEMA) + if spec.openapi_version.major >= 3: + response = {"content": {"application/json": {"schema": schema}}} + else: + response = {"schema": schema} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_response_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + response = {"headers": {"header": header}} + spec.components.response("Response", response) + resp = get_responses(spec)["Response"] + self.assert_schema_refs(spec, resp["headers"]["header"]["schema"]) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_examples(self, spec): + parameter = { + "examples": {"example_1": "Example_1"}, + } + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_components_resolve_parameter_schemas(self, spec): + parameter = {"schema": "PetSchema"} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_parameter_schemas_v3(self, spec): + parameter = {"content": {"application/json": {"schema": "PetSchema"}}} + spec.components.parameter("param", "path", parameter) + param = get_parameters(spec)["param"] + schema = param["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + def test_components_resolve_refs_in_parameter_schema(self, spec): + parameter = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.parameter("param", "path", parameter) + self.assert_schema_refs(spec, get_parameters(spec)["param"]["schema"]) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_schema(self, spec): + header = {"name": "Pet", "schema": "PetSchema"} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_header_examples(self, spec): + header = {"name": "Pet", "examples": {"example_1": "Example_1"}} + spec.components.header("header", header) + header = get_headers(spec)["header"] + assert header["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_components_resolve_refs_in_header_schema(self, spec): + header = {"schema": copy.deepcopy(self.REFS_SCHEMA)} + spec.components.header("header", header) + self.assert_schema_refs(spec, get_headers(spec)["header"]["schema"]) + + def test_schema_lazy(self, spec): + spec.components.schema("Pet_1", {"properties": self.properties}, lazy=False) + spec.components.schema("Pet_2", {"properties": self.properties}, lazy=True) + schemas = get_schemas(spec) + assert "Pet_1" in schemas + assert "Pet_2" not in schemas + spec.components.schema("PetFriend", {"oneOf": ["Pet_1", "Pet_2"]}) + schemas = get_schemas(spec) + assert "Pet_2" in schemas + assert schemas["Pet_2"]["properties"] == self.properties + + def test_response_lazy(self, spec): + response_1 = {"description": "Response 1"} + response_2 = {"description": "Response 2"} + spec.components.response("Response_1", response_1, lazy=False) + spec.components.response("Response_2", response_2, lazy=True) + responses = get_responses(spec) + assert "Response_1" in responses + assert "Response_2" not in responses + spec.path("/path", operations={"get": {"responses": {"200": "Response_2"}}}) + responses = get_responses(spec) + assert "Response_2" in responses + + def test_parameter_lazy(self, spec): + parameter = {"format": "int64", "type": "integer"} + spec.components.parameter("Param_1", "path", parameter, lazy=False) + spec.components.parameter("Param_2", "path", parameter, lazy=True) + params = get_parameters(spec) + assert "Param_1" in params + assert "Param_2" not in params + spec.path("/path", operations={"get": {"parameters": ["Param_1", "Param_2"]}}) + assert "Param_2" in params + + # Referenced headers are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_header_lazy(self, spec): + header = {"schema": {"type": "string"}} + spec.components.header("Header_1", header, lazy=False) + spec.components.header("Header_2", header, lazy=True) + headers = get_headers(spec) + assert "Header_1" in headers + assert "Header_2" not in headers + spec.path( + "/path", + operations={ + "get": {"responses": {"200": {"headers": {"header_2": "Header_2"}}}} + }, + ) + assert "Header_2" in headers + + # Referenced examples are only supported in OAS 3.x + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_example_lazy(self, spec): + spec.components.example("Example_1", {"value": {"a": "b"}}, lazy=False) + spec.components.example("Example_2", {"value": {"a": "b"}}, lazy=True) + examples = get_examples(spec) + assert "Example_1" in examples + assert "Example_2" not in examples + spec.path( + "/path", + operations={ + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "examples": {"example_2": "Example_2"} + } + } + } + } + } + }, + ) + assert "Example_2" in examples + + +class TestPath(RefsSchemaTestMixin): + paths = { + "/pet/{petId}": { + "get": { + "parameters": [ + { + "required": True, + "format": "int64", + "name": "petId", + "in": "path", + "type": "integer", + "description": "ID of pet that needs to be fetched", + } + ], + "responses": { + "200": {"description": "successful operation"}, + "400": {"description": "Invalid ID supplied"}, + "404": {"description": "Pet not found"}, + }, + "produces": ["application/json", "application/xml"], + "operationId": "getPetById", + "summary": "Find pet by ID", + "description": ( + "Returns a pet when ID < 10. " + "ID > 10 or nonintegers will simulate API error conditions" + ), + "tags": ["pet"], + } + } + } + + def test_path(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.path( + path="/pet/{petId}", + operations=dict( + get=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId=route_spec["operationId"], + summary=route_spec["summary"], + description=route_spec["description"], + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"] == route_spec["parameters"] + assert p["responses"] == route_spec["responses"] + assert p["operationId"] == route_spec["operationId"] + assert p["summary"] == route_spec["summary"] + assert p["description"] == route_spec["description"] + assert p["tags"] == route_spec["tags"] + + def test_paths_maintain_order(self, spec): + spec.path(path="/path1") + spec.path(path="/path2") + spec.path(path="/path3") + spec.path(path="/path4") + assert list(spec.to_dict()["paths"].keys()) == [ + "/path1", + "/path2", + "/path3", + "/path4", + ] + + def test_path_is_chainable(self, spec): + spec.path(path="/path1").path("/path2") + assert list(spec.to_dict()["paths"].keys()) == ["/path1", "/path2"] + + def test_path_methods_maintain_order(self, spec): + methods = ["get", "post", "put", "patch", "delete", "head", "options"] + for method in methods: + spec.path(path="/path", operations={method: {}}) + assert list(spec.to_dict()["paths"]["/path"]) == methods + + def test_path_merges_paths(self, spec): + """Test that adding a second HTTP method to an existing path performs + a merge operation instead of an overwrite""" + path = "/pet/{petId}" + route_spec = self.paths[path]["get"] + spec.path(path=path, operations=dict(get=route_spec)) + spec.path( + path=path, + operations=dict( + put=dict( + parameters=route_spec["parameters"], + responses=route_spec["responses"], + produces=route_spec["produces"], + operationId="updatePet", + summary="Updates an existing Pet", + description="Use this method to make changes to Pet `petId`", + tags=route_spec["tags"], + ) + ), + ) + + p = get_paths(spec)[path] + assert "get" in p + assert "put" in p + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_path_called_twice_with_same_operations_parameters(self, openapi_version): + """Test calling path twice with same operations or parameters + + operations and parameters being mutated by clean_operations and plugin helpers + should not make path fail on second call + """ + + class TestPlugin(BasePlugin): + def path_helper(self, path, operations, parameters, **kwargs): + """Mutate operations and parameters""" + operations.update({"post": {"responses": {"201": "201ResponseRef"}}}) + parameters.append("ParamRef_3") + return path + + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=[TestPlugin()], + ) + + path = "/pet/{petId}" + parameters = ["ParamRef_1"] + operation = { + "parameters": ["ParamRef_2"], + "responses": {"200": "200ResponseRef"}, + } + + spec.path(path=path, operations={"get": operation}, parameters=parameters) + spec.path(path=path, operations={"put": operation}, parameters=parameters) + operations = (get_paths(spec))[path] + assert ( + operations["get"] + == operations["put"] + == { + "parameters": [build_ref(spec, "parameter", "ParamRef_2")], + "responses": {"200": build_ref(spec, "response", "200ResponseRef")}, + } + ) + assert operations["parameters"] == [ + build_ref(spec, "parameter", "ParamRef_1"), + build_ref(spec, "parameter", "ParamRef_3"), + ] + + def test_path_ensures_path_parameters_required(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put=dict(parameters=[{"name": "petId", "in": "path"}])), + ) + assert get_paths(spec)[path]["put"]["parameters"][0]["required"] is True + + def test_path_with_no_path_raises_error(self, spec): + message = "Path template is not specified" + with pytest.raises(APISpecError, match=message): + spec.path() + + def test_path_summary_description(self, spec): + summary = "Operations on a Pet" + description = "Operations on a Pet identified by its ID" + spec.path(path="/pet/{petId}", summary=summary, description=description) + + p = get_paths(spec)["/pet/{petId}"] + assert p["summary"] == summary + assert p["description"] == description + + def test_path_resolves_parameter(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path="/pet/{petId}", operations={"get": {"parameters": ["test_parameter"]}} + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["parameters"][0] == build_ref(spec, "parameter", "test_parameter") + + @pytest.mark.parametrize( + "parameters", + ([{"name": "petId"}], [{"in": "path"}]), # missing "in" # missing "name" + ) + def test_path_invalid_parameter(self, spec, parameters): + path = "/pet/{petId}" + + with pytest.raises(InvalidParameterError): + spec.path(path=path, operations=dict(put={}, get={}), parameters=parameters) + + def test_parameter_duplicate(self, spec): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ] + } + }, + ) + + with pytest.raises(DuplicateParameterError): + spec.path( + path="/pet/{petId}", + operations={ + "get": { + "parameters": [ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + ] + } + }, + ) + + def test_global_parameters(self, spec): + path = "/pet/{petId}" + route_spec = self.paths["/pet/{petId}"]["get"] + + spec.components.parameter("test_parameter", "path", route_spec["parameters"][0]) + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[{"name": "petId", "in": "path"}, "test_parameter"], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + build_ref(spec, "parameter", "test_parameter"), + ] + + def test_global_parameter_duplicate(self, spec): + path = "/pet/{petId}" + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "query"}, + ], + ) + + assert get_paths(spec)[path]["parameters"] == [ + {"name": "petId", "in": "path", "required": True}, + {"name": "petId", "in": "query"}, + ] + + with pytest.raises(DuplicateParameterError): + spec.path( + path=path, + operations=dict(put={}, get={}), + parameters=[ + {"name": "petId", "in": "path"}, + {"name": "petId", "in": "path"}, + "test_parameter", + ], + ) + + def test_path_resolves_response(self, spec): + route_spec = self.paths["/pet/{petId}"]["get"] + spec.components.response("test_response", route_spec["responses"]["200"]) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {"200": "test_response"}}}, + ) + p = get_paths(spec)["/pet/{petId}"]["get"] + assert p["responses"]["200"] == build_ref(spec, "response", "test_response") + + def test_path_response_with_HTTPStatus_code(self, spec): + code = HTTPStatus(200) + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {code: "test_response"}}}, + ) + + assert "200" in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_response_with_status_code_range(self, spec, recwarn): + status_code = "2XX" + + spec.path( + path="/pet/{petId}", + operations={"get": {"responses": {status_code: "test_response"}}}, + ) + + if spec.openapi_version.major < 3: + assert len(recwarn) == 1 + assert recwarn.pop(UserWarning) + + assert status_code in get_paths(spec)["/pet/{petId}"]["get"]["responses"] + + def test_path_check_invalid_http_method(self, spec): + spec.path("/pet/{petId}", operations={"get": {}}) + spec.path("/pet/{petId}", operations={"x-dummy": {}}) + message = "One or more HTTP methods are invalid" + with pytest.raises(APISpecError, match=message): + spec.path("/pet/{petId}", operations={"dummy": {}}) + + def test_path_resolve_response_schema(self, spec): + schema = {"schema": "PetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "PetSchema") + + # callbacks only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_callbacks(self, spec): + parameter = {"name": "petId", "in": "query", "schema": "PetSchema"} + spec.path( + "/pet/{petId}", + operations={ + "get": { + "callbacks": { + "onEvent": { + "/callback/{petId}": { + "post": { + "parameters": [parameter], + "requestBody": { + "content": { + "application/json": {"schema": "PetSchema"} + } + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": "PetSchema" + } + } + } + }, + } + } + } + }, + } + }, + ) + path = get_paths(spec)["/pet/{petId}"] + schema_ref = build_ref(spec, "schema", "PetSchema") + callback_op = path["get"]["callbacks"]["onEvent"]["/callback/{petId}"]["post"] + assert callback_op["parameters"][0]["schema"] == schema_ref + assert ( + callback_op["requestBody"]["content"]["application/json"]["schema"] + == schema_ref + ) + assert ( + callback_op["responses"]["200"]["content"]["application/json"]["schema"] + == schema_ref + ) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body(self, spec): + spec.path( + "/pet/{petId}", + operations={ + "get": { + "requestBody": { + "content": {"application/json": {"schema": "PetSchema"}} + } + } + }, + ) + assert get_paths(spec)["/pet/{petId}"]["get"]["requestBody"]["content"][ + "application/json" + ]["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header(self, spec): + response = {"headers": {"header_1": "Header_1"}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1 == build_ref(spec, "header", "Header_1") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_schema(self, spec): + response = {"headers": {"header_1": {"name": "Pet", "schema": "PetSchema"}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["schema"] == build_ref(spec, "schema", "PetSchema") + + # "headers" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_header_examples(self, spec): + response = { + "headers": { + "header_1": {"name": "Pet", "examples": {"example_1": "Example_1"}} + } + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + header_1 = resp["headers"]["header_1"] + assert header_1["examples"]["example_1"] == build_ref( + spec, "example", "Example_1" + ) + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_response_examples(self, spec): + response = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": response}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + example_1 = resp["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_request_body_examples(self, spec): + request_body = { + "content": {"application/json": {"examples": {"example_1": "Example_1"}}} + } + spec.path("/pet/{petId}", operations={"get": {"requestBody": request_body}}) + reqbdy = get_paths(spec)["/pet/{petId}"]["get"]["requestBody"] + example_1 = reqbdy["content"]["application/json"]["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + # "examples" components section only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_parameter_examples(self, spec): + parameter = { + "name": "test", + "in": "query", + "examples": {"example_1": "Example_1"}, + } + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + example_1 = param["examples"]["example_1"] + assert example_1 == build_ref(spec, "example", "Example_1") + + def test_path_resolve_parameter_schemas(self, spec): + parameter = {"name": "test", "in": "query", "schema": "PetSchema"} + spec.path("/pet/{petId}", operations={"get": {"parameters": [parameter]}}) + param = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0] + assert param["schema"] == build_ref(spec, "schema", "PetSchema") + + def test_path_resolve_refs_in_response_schema(self, spec): + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + else: + schema = {"schema": self.REFS_SCHEMA} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + def test_path_resolve_refs_in_parameter_schema(self, spec): + schema = copy.copy({"schema": self.REFS_SCHEMA}) + schema["in"] = "query" + schema["name"] = "test" + spec.path("/pet/{petId}", operations={"get": {"parameters": [schema]}}) + schema = get_paths(spec)["/pet/{petId}"]["get"]["parameters"][0]["schema"] + self.assert_schema_refs(spec, schema) + + # requestBody only exists in OAS 3 + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_path_resolve_refs_in_request_body_schema(self, spec): + schema = {"content": {"application/json": {"schema": self.REFS_SCHEMA}}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + schema = resp["content"]["application/json"]["schema"] + self.assert_schema_refs(spec, schema) + + +class TestPlugins: + @staticmethod + def make_test_plugin(return_none=False): + class TestPlugin(BasePlugin): + """Test Plugin + + return_none allows to check plugin helpers returning ``None`` + Inputs are mutated to allow testing only a copy is passed. + """ + + def schema_helper(self, name, definition, **kwargs): + definition.pop("dummy", None) + if not return_none: + return {"properties": {"name": {"type": "string"}}} + + def parameter_helper(self, parameter, **kwargs): + parameter.pop("dummy", None) + if not return_none: + return {"description": "some parameter"} + + def response_helper(self, response, **kwargs): + response.pop("dummy", None) + if not return_none: + return {"description": "42"} + + def header_helper(self, header, **kwargs): + header.pop("dummy", None) + if not return_none: + return {"description": "some header"} + + def path_helper(self, path, operations, parameters, **kwargs): + if not return_none: + if path == "/path_1": + operations.update({"get": {"responses": {"200": {}}}}) + parameters.append({"name": "page", "in": "query"}) + return "/path_1_modified" + + def operation_helper(self, path, operations, **kwargs): + if path == "/path_2": + operations["post"] = {"responses": {"201": {}}} + + return TestPlugin() + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_schema_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + schema = {"dummy": "dummy"} + spec.components.schema("Pet", schema) + definitions = get_schemas(spec) + if return_none: + assert definitions["Pet"] == {} + else: + assert definitions["Pet"] == {"properties": {"name": {"type": "string"}}} + # Check original schema is not modified + assert schema == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_parameter_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + parameter = {"dummy": "dummy"} + spec.components.parameter("Pet", "body", parameter) + parameters = get_parameters(spec) + if return_none: + assert parameters["Pet"] == {"in": "body", "name": "Pet"} + else: + assert parameters["Pet"] == { + "in": "body", + "name": "Pet", + "description": "some parameter", + } + # Check original parameter is not modified + assert parameter == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_response_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + response = {"dummy": "dummy"} + spec.components.response("Pet", response) + responses = get_responses(spec) + if return_none: + assert responses["Pet"] == {} + else: + assert responses["Pet"] == {"description": "42"} + # Check original response is not modified + assert response == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("3.0.0",)) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_header_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + header = {"dummy": "dummy"} + spec.components.header("Pet", header) + headers = get_headers(spec) + if return_none: + assert headers["Pet"] == {} + else: + assert headers["Pet"] == { + "description": "some header", + } + # Check original header is not modified + assert header == {"dummy": "dummy"} + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + @pytest.mark.parametrize("return_none", (True, False)) + def test_plugin_path_helper_is_used(self, openapi_version, return_none): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(return_none),), + ) + spec.path("/path_1") + paths = get_paths(spec) + assert len(paths) == 1 + if return_none: + assert paths["/path_1"] == {} + else: + assert paths["/path_1_modified"] == { + "get": {"responses": {"200": {}}}, + "parameters": [{"in": "query", "name": "page"}], + } + + @pytest.mark.parametrize("openapi_version", ("2.0", "3.0.0")) + def test_plugin_operation_helper_is_used(self, openapi_version): + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version=openapi_version, + plugins=(self.make_test_plugin(),), + ) + spec.path("/path_2", operations={"post": {"responses": {"200": {}}}}) + paths = get_paths(spec) + assert len(paths) == 1 + assert paths["/path_2"] == {"post": {"responses": {"201": {}}}} + + +class TestPluginsOrder: + class OrderedPlugin(BasePlugin): + def __init__(self, index, output): + super().__init__() + self.index = index + self.output = output + + def path_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_path") + + def operation_helper(self, path, operations, **kwargs): + self.output.append(f"plugin_{self.index}_operations") + + def test_plugins_order(self): + """Test plugins execution order in APISpec.path + + - All path helpers are called, then all operation helpers, then all response helpers. + - At each step, helpers are executed in the order the plugins are passed to APISpec. + """ + output = [] + spec = APISpec( + title="Swagger Petstore", + version="1.0.0", + openapi_version="3.0.0", + plugins=(self.OrderedPlugin(1, output), self.OrderedPlugin(2, output)), + ) + spec.path("/path", operations={"get": {"responses": {200: {}}}}) + assert output == [ + "plugin_1_path", + "plugin_2_path", + "plugin_1_operations", + "plugin_2_operations", + ] diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow.py new file mode 100644 index 0000000000000000000000000000000000000000..0b863f41a74211f3c296d6239d5ed6d6ac9d479c --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow.py @@ -0,0 +1,1342 @@ +import json + +import pytest +from marshmallow import Schema +from marshmallow.fields import DateTime, Dict, Field, List, Nested, String, TimeDelta + +from apispec import APISpec +from apispec.exceptions import APISpecError +from apispec.ext.marshmallow import MarshmallowPlugin, common + +from .schemas import ( + AnalysisSchema, + AnalysisWithListSchema, + DefaultValuesSchema, + OrderedSchema, + PatternedObjectSchema, + PetSchema, + RunSchema, + SampleSchema, + SelfReferencingSchema, +) +from .utils import ( + build_ref, + get_headers, + get_parameters, + get_paths, + get_responses, + get_schemas, +) + + +class TestDefinitionHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_as_definition(self, spec, schema): + spec.components.schema("Pet", schema=schema) + definitions = get_schemas(spec) + props = definitions["Pet"]["properties"] + + assert props["id"]["type"] == "integer" + assert props["name"]["type"] == "string" + + def test_schema_helper_without_schema(self, spec): + spec.components.schema("Pet", {"properties": {"key": {"type": "integer"}}}) + definitions = get_schemas(spec) + assert definitions["Pet"]["properties"] == {"key": {"type": "integer"}} + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize( + "schema", [AnalysisWithListSchema, AnalysisWithListSchema()] + ) + def test_resolve_schema_dict_auto_reference_in_list(self, schema): + def resolver(schema): + schema_cls = common.resolve_schema_cls(schema) + return schema_cls.__name__ + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + spec.components.schema("analysis", schema=schema) + spec.path( + "/test", + operations={ + "get": { + "responses": { + "200": {"schema": build_ref(spec, "schema", "analysis")} + } + } + }, + ) + definitions = get_schemas(spec) + assert 3 == len(definitions) + + assert "analysis" in definitions + assert "SampleSchema" in definitions + assert "RunSchema" in definitions + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_resolve_schema_dict_auto_reference_return_none(self, schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + with pytest.raises(KeyError): + get_schemas(spec) + + with pytest.raises( + APISpecError, match="Name resolver returned None for schema" + ): + spec.components.schema("analysis", schema=schema) + + @pytest.mark.parametrize("schema", [AnalysisSchema, AnalysisSchema()]) + def test_warning_when_schema_added_twice(self, spec, schema): + spec.components.schema("Analysis", schema=schema) + with pytest.warns(UserWarning, match="has already been added to the spec"): + spec.components.schema("DuplicateAnalysis", schema=schema) + + def test_schema_instances_with_different_modifiers_added(self, spec): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema, exclude=("name",)) + + spec.components.schema("Pet", schema=PetSchema()) + spec.components.schema("Pet_Exclude", schema=PetSchema(exclude=("name",))) + + spec.components.schema("MultiModifierSchema", schema=MultiModifierSchema) + + definitions = get_schemas(spec) + pet_unmodified_ref = definitions["MultiModifierSchema"]["properties"][ + "pet_unmodified" + ] + assert pet_unmodified_ref == build_ref(spec, "schema", "Pet") + + pet_exclude = definitions["MultiModifierSchema"]["properties"]["pet_exclude"] + assert pet_exclude == build_ref(spec, "schema", "Pet_Exclude") + + def test_schema_instance_with_different_modifers_custom_resolver(self, recwarn): + class MultiModifierSchema(Schema): + pet_unmodified = Nested(PetSchema) + pet_exclude = Nested(PetSchema(partial=True)) + + def resolver(schema): + schema_instance = common.resolve_schema_instance(schema) + prefix = "Partial-" if schema_instance.partial else "" + schema_cls = common.resolve_schema_cls(schema) + name = prefix + schema_cls.__name__ + if name.endswith("Schema"): + return name[:-6] or name + return name + + spec = APISpec( + title="Test Custom Resolver for Partial", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("NameClashSchema", schema=MultiModifierSchema) + assert not recwarn + + def test_schema_with_clashing_names(self, spec): + class Pet(PetSchema): + another_field = String() + + class NameClashSchema(Schema): + pet_1 = Nested(PetSchema) + pet_2 = Nested(Pet) + + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + spec.components.schema("NameClashSchema", schema=NameClashSchema) + + definitions = get_schemas(spec) + + assert "Pet" in definitions + assert "Pet1" in definitions + + def test_resolve_nested_schema_many_true_resolver_return_none(self): + def resolver(schema): + return None + + class PetFamilySchema(Schema): + pets_1 = Nested(PetSchema, many=True) + pets_2 = List(Nested(PetSchema)) + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + + spec.components.schema("PetFamily", schema=PetFamilySchema) + props = get_schemas(spec)["PetFamily"]["properties"] + pets_1 = props["pets_1"] + pets_2 = props["pets_2"] + assert pets_1["type"] == pets_2["type"] == "array" + + +class TestComponentParameterHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter(self, spec, schema): + param = {"schema": schema} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_parameter_with_content(self, spec, schema): + param = {"content": {"application/json": {"schema": schema}}} + spec.components.parameter("Pet", "body", param) + parameter = get_parameters(spec)["Pet"] + assert parameter["in"] == "body" + reference = parameter["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestComponentResponseHelper: + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response(self, spec, schema): + if spec.openapi_version.major < 3: + resp = {"schema": schema} + else: + resp = {"content": {"application/json": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + if spec.openapi_version.major < 3: + reference = response["schema"] + else: + reference = response["content"]["application/json"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_response_header(self, spec, schema): + resp = {"headers": {"PetHeader": {"schema": schema}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + reference = response["headers"]["PetHeader"]["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["id"]["type"] == "integer" + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + def test_content_without_schema(self, spec): + resp = {"content": {"application/json": {"example": {"name": "Example"}}}} + spec.components.response("GetPetOk", resp) + response = get_responses(spec)["GetPetOk"] + assert response == resp + + +class TestComponentHeaderHelper: + @pytest.mark.parametrize("spec", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("schema", [PetSchema, PetSchema()]) + def test_can_use_schema_in_header(self, spec, schema): + param = {"schema": schema} + spec.components.header("Pet", param) + header = get_headers(spec)["Pet"] + reference = header["schema"] + assert reference == build_ref(spec, "schema", "Pet") + + resolved_schema = spec.components.schemas["Pet"] + assert resolved_schema["properties"]["name"]["type"] == "string" + assert resolved_schema["properties"]["password"]["type"] == "string" + assert resolved_schema["properties"]["id"]["type"] == "integer" + + +class TestCustomField: + def test_can_use_custom_field_decorator(self, spec_fixture): + class CustomNameA(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type(CustomNameA, DateTime) + + class CustomNameB(Field): + pass + + spec_fixture.marshmallow_plugin.map_to_openapi_type( + CustomNameB, "integer", "int32" + ) + + class BadCustomField(Field): + pass + + with pytest.raises(TypeError): + spec_fixture.marshmallow_plugin.map_to_openapi_type( + BadCustomField, "integer" + ) + + class CustomPetASchema(PetSchema): + name = CustomNameA() + + class CustomPetBSchema(PetSchema): + name = CustomNameB() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("CustomPetA", schema=CustomPetASchema) + spec_fixture.spec.components.schema("CustomPetB", schema=CustomPetBSchema) + + props_0 = get_schemas(spec_fixture.spec)["Pet"]["properties"] + props_a = get_schemas(spec_fixture.spec)["CustomPetA"]["properties"] + props_b = get_schemas(spec_fixture.spec)["CustomPetB"]["properties"] + + assert props_0["name"]["type"] == "string" + assert "format" not in props_0["name"] + + assert props_a["name"]["type"] == "string" + assert props_a["name"]["format"] == "date-time" + + assert props_b["name"]["type"] == "integer" + assert props_b["name"]["format"] == "int32" + + +def get_nested_schema(schema, field_name): + try: + return schema._declared_fields[field_name]._schema + except AttributeError: + return schema._declared_fields[field_name]._Nested__schema + + +class TestOperationHelper: + @pytest.fixture + def make_pet_callback_spec(self, spec_fixture): + def _make_pet_spec(operations): + spec_fixture.spec.path( + path="/pet", + operations={ + "post": {"callbacks": {"petEvent": {"petCallbackUrl": operations}}} + }, + ) + return spec_fixture + + return _make_pet_spec + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_v2(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "schema": pet_schema, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert get["responses"]["200"]["schema"]["type"] == "array" + schema_reference = get["responses"]["200"]["schema"]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["schema"] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_v3(self, spec_fixture, pet_schema): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), PetSchema(many=True), "tests.schemas.PetSchema"), + ) + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_v3(self, make_pet_callback_spec, pet_schema): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": {"application/json": {"schema": pet_schema}}, + "description": "successful operation", + "headers": {"PetHeader": {"schema": pet_schema}}, + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + if isinstance(pet_schema, Schema) and pet_schema.many is True: + assert ( + get["responses"]["200"]["content"]["application/json"]["schema"]["type"] + == "array" + ) + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ]["items"] + assert ( + get["responses"]["200"]["headers"]["PetHeader"]["schema"]["type"] + == "array" + ) + header_reference = get["responses"]["200"]["headers"]["PetHeader"][ + "schema" + ]["items"] + else: + schema_reference = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + header_reference = get["responses"]["200"]["headers"]["PetHeader"]["schema"] + + assert schema_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert header_reference == build_ref(spec_fixture.spec, "schema", "Pet") + assert len(spec_fixture.spec.components.schemas) == 1 + resolved_schema = spec_fixture.spec.components.schemas["Pet"] + assert resolved_schema == spec_fixture.openapi.schema2jsonschema(PetSchema) + assert get["responses"]["200"]["description"] == "successful operation" + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_expand_parameters_v2(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "parameters": [ + { + "in": "body", + "description": "a pet schema", + "required": True, + "name": "pet", + "schema": PetSchema, + } + ] + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + post = p["post"] + assert post["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema, + location="body", + required=True, + name="pet", + description="a pet schema", + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_expand_parameters_v3(self, spec_fixture): + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + get = p["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = p["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_expand_parameters_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "description": "a pet schema", + "required": True, + "content": {"application/json": {"schema": PetSchema}}, + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["parameters"] == spec_fixture.openapi.schema2parameters( + PetSchema(), location="query" + ) + for parameter in get["parameters"]: + description = parameter.get("description", False) + assert description + name = parameter["name"] + assert description == PetSchema.description[name] + post = c["post"] + post_schema = spec_fixture.marshmallow_plugin.resolver.resolve_schema_dict( + PetSchema + ) + assert ( + post["requestBody"]["content"]["application/json"]["schema"] == post_schema + ) + assert post["requestBody"]["description"] == "a pet schema" + assert post["requestBody"]["required"] + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_if_available_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": {"content": {"application/json": {"schema": PetSchema}}} + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec_fixture.spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v2(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", operations={"get": {"responses": {200: {"schema": PetSchema}}}} + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == build_ref(spec, "schema", "Pet") + + def test_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": PetSchema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_allof_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.components.schema("Sample", schema=SampleSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": {200: {"schema": {"allOf": [PetSchema, SampleSchema]}}} + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "allOf": [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + @pytest.mark.parametrize("combinator", ["oneOf", "anyOf", "allOf"]) + def test_schema_resolver_oneof_anyof_allof_v3(self, spec_fixture, combinator): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": {combinator: [PetSchema, SampleSchema]} + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + combinator: [ + build_ref(spec_fixture.spec, "schema", "Pet"), + build_ref(spec_fixture.spec, "schema", "Sample"), + ] + } + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_resolver_not_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": {"not": PetSchema}}}}}, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_resolver_not_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": {"schema": {"not": PetSchema}} + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "not": build_ref(spec_fixture.spec, "schema", "Pet"), + } + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v2(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="2.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={"get": {"responses": {200: {"schema": pet_schema}}}}, + ) + get = get_paths(spec)["/pet"]["get"] + assert "properties" in get["responses"]["200"]["schema"] + + @pytest.mark.parametrize( + "pet_schema", + (PetSchema, PetSchema(), "tests.schemas.PetSchema"), + ) + def test_schema_name_resolver_returns_none_v3(self, pet_schema): + def resolver(schema): + return None + + spec = APISpec( + title="Test resolver returns None", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.path( + path="/pet", + operations={ + "get": { + "responses": { + 200: {"content": {"application/json": {"schema": pet_schema}}} + } + } + }, + ) + get = get_paths(spec)["/pet"]["get"] + assert ( + "properties" + in get["responses"]["200"]["content"]["application/json"]["schema"] + ) + + def test_callback_schema_uses_ref_if_available_name_resolver_returns_none_v3(self): + def resolver(schema): + return None + + spec = APISpec( + title="Test auto-reference", + version="0.1", + openapi_version="3.0.0", + plugins=(MarshmallowPlugin(schema_name_resolver=resolver),), + ) + spec.components.schema("Pet", schema=PetSchema) + spec.path( + path="/pet", + operations={ + "post": { + "callbacks": { + "petEvent": { + "petCallbackUrl": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": PetSchema + } + } + } + } + } + } + } + } + } + }, + ) + p = get_paths(spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"][ + "schema" + ] == build_ref(spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v2( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": {"parameters": [{"in": "body", "schema": PetSchema}]}, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" not in p["get"]["parameters"][0] + post = p["post"] + assert len(post["parameters"]) == 1 + assert post["parameters"][0]["schema"] == build_ref( + spec_fixture.spec, "schema", "Pet" + ) + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, spec_fixture + ): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + }, + ) + p = get_paths(spec_fixture.spec)["/pet"] + assert "schema" in p["get"]["parameters"][0] + post = p["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_uses_ref_in_parameters_and_request_body_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": {"parameters": [{"in": "query", "schema": PetSchema}]}, + "post": { + "requestBody": { + "content": {"application/json": {"schema": PetSchema}} + } + }, + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + assert "schema" in c["get"]["parameters"][0] + post = c["post"] + schema_ref = post["requestBody"]["content"]["application/json"]["schema"] + assert schema_ref == build_ref(spec_fixture.spec, "schema", "Pet") + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "petSchema", + "in": "body", + "schema": {"type": "array", "items": PetSchema}, + } + ], + "responses": { + 200: {"schema": {"type": "array", "items": PetSchema}} + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + assert get["parameters"][0]["schema"] == resolved_schema + assert get["responses"]["200"]["schema"] == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_array_uses_ref_if_available_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/pet", + operations={ + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + 200: { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + }, + ) + get = get_paths(spec_fixture.spec)["/pet"]["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_array_uses_ref_if_available_v3( + self, make_pet_callback_spec + ): + spec_fixture = make_pet_callback_spec( + { + "get": { + "parameters": [ + { + "name": "Pet", + "in": "query", + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + }, + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": {"type": "array", "items": PetSchema} + } + } + } + }, + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert len(get["parameters"]) == 1 + resolved_schema = { + "type": "array", + "items": build_ref(spec_fixture.spec, "schema", "Pet"), + } + request_schema = get["parameters"][0]["content"]["application/json"]["schema"] + assert request_schema == resolved_schema + response_schema = get["responses"]["200"]["content"]["application/json"][ + "schema" + ] + assert response_schema == resolved_schema + + @pytest.mark.parametrize("spec_fixture", ("2.0",), indirect=True) + def test_schema_partially_v2(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_schema_partially_v3(self, spec_fixture): + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + spec_fixture.spec.path( + path="/parents", + operations={ + "get": { + "responses": { + 200: { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + }, + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + @pytest.mark.parametrize("spec_fixture", ("3.0.0",), indirect=True) + def test_callback_schema_partially_v3(self, make_pet_callback_spec): + spec_fixture = make_pet_callback_spec( + { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "mother": PetSchema, + "father": PetSchema, + }, + } + } + } + } + } + } + } + ) + p = get_paths(spec_fixture.spec)["/pet"] + c = p["post"]["callbacks"]["petEvent"]["petCallbackUrl"] + get = c["get"] + assert get["responses"]["200"]["content"]["application/json"]["schema"] == { + "type": "object", + "properties": { + "mother": build_ref(spec_fixture.spec, "schema", "Pet"), + "father": build_ref(spec_fixture.spec, "schema", "Pet"), + }, + } + + def test_parameter_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + param = {"schema": PetSchema} + else: + param = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.parameter("Pet", "body", param) + spec_fixture.spec.path( + path="/parents", operations={"get": {"parameters": ["Pet"]}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["parameters"] == [build_ref(spec_fixture.spec, "parameter", "Pet")] + + def test_response_reference(self, spec_fixture): + if spec_fixture.spec.openapi_version.major < 3: + resp = {"schema": PetSchema} + else: + resp = {"content": {"application/json": {"schema": PetSchema}}} + spec_fixture.spec.components.response("Pet", resp) + spec_fixture.spec.path( + path="/parents", operations={"get": {"responses": {"200": "Pet"}}} + ) + get = get_paths(spec_fixture.spec)["/parents"]["get"] + assert get["responses"] == { + "200": build_ref(spec_fixture.spec, "response", "Pet") + } + + def test_schema_global_state_untouched_2json(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2jsonschema(RunSchema) + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_schema_global_state_untouched_2parameters(self, spec_fixture): + assert get_nested_schema(RunSchema, "sample") is None + data = spec_fixture.openapi.schema2parameters(RunSchema, location="json") + json.dumps(data) + assert get_nested_schema(RunSchema, "sample") is None + + def test_resolve_schema_dict_ref_as_string(self, spec): + """Test schema ref passed as string""" + # The case tested here is a reference passed as string, not a + # marshmallow Schema passed by name as string. We want to ensure the + # MarshmallowPlugin does not interfere with the feature interpreting + # strings as references. Therefore, we use a specific name to ensure + # there is no Schema with that name in the marshmallow registry from + # somewhere else in the tests. + # e.g. PetSchema is in the registry already so it wouldn't work. + schema = {"schema": "SomeSpecificPetSchema"} + if spec.openapi_version.major >= 3: + schema = {"content": {"application/json": schema}} + spec.path("/pet/{petId}", operations={"get": {"responses": {"200": schema}}}) + resp = get_paths(spec)["/pet/{petId}"]["get"]["responses"]["200"] + if spec.openapi_version.major < 3: + schema = resp["schema"] + else: + schema = resp["content"]["application/json"]["schema"] + assert schema == build_ref(spec, "schema", "SomeSpecificPetSchema") + + +class TestCircularReference: + def test_circular_referencing_schemas(self, spec): + spec.components.schema("Analysis", schema=AnalysisSchema) + definitions = get_schemas(spec) + ref = definitions["Analysis"]["properties"]["sample"] + assert ref == build_ref(spec, "schema", "Sample") + + +# Regression tests for issue #55 +class TestSelfReference: + def test_self_referencing_field_single(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + ref = definitions["SelfReference"]["properties"]["single"] + assert ref == build_ref(spec, "schema", "SelfReference") + + def test_self_referencing_field_many(self, spec): + spec.components.schema("SelfReference", schema=SelfReferencingSchema) + definitions = get_schemas(spec) + result = definitions["SelfReference"]["properties"]["multiple"] + assert result == { + "type": "array", + "items": build_ref(spec, "schema", "SelfReference"), + } + + +class TestOrderedSchema: + def test_ordered_schema(self, spec): + spec.components.schema("Ordered", schema=OrderedSchema) + result = get_schemas(spec)["Ordered"]["properties"] + assert list(result.keys()) == ["field1", "field2", "field3", "field4", "field5"] + + +class TestFieldWithCustomProps: + def test_field_with_custom_props(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count"] + assert "x-count" in result + assert result["x-count"] == 1 + + def test_field_with_custom_props_passed_as_snake_case(self, spec): + spec.components.schema("PatternedObject", schema=PatternedObjectSchema) + result = get_schemas(spec)["PatternedObject"]["properties"]["count2"] + assert "x-count2" in result + assert result["x-count2"] == 2 + + +class TestSchemaWithDefaultValues: + def test_schema_with_default_values(self, spec): + spec.components.schema("DefaultValuesSchema", schema=DefaultValuesSchema) + definitions = get_schemas(spec) + props = definitions["DefaultValuesSchema"]["properties"] + assert props["number_auto_default"]["default"] == 12 + assert props["number_manual_default"]["default"] == 42 + assert "default" not in props["string_callable_default"] + assert props["string_manual_default"]["default"] == "Manual" + assert "default" not in props["numbers"] + + +class TestDictValues: + def test_dict_values_resolve_to_additional_properties(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=String()) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {"type": "string"}} + + def test_dict_with_empty_values_field(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict() + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == {"type": "object", "additionalProperties": {}} + + def test_dict_with_nested(self, spec): + class SchemaWithDict(Schema): + dict_field = Dict(values=Nested(PetSchema)) + + spec.components.schema("SchemaWithDict", schema=SchemaWithDict) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithDict"]["properties"]["dict_field"] + assert result == { + "additionalProperties": build_ref(spec, "schema", "Pet"), + "type": "object", + } + + +class TestList: + def test_list_with_nested(self, spec): + class SchemaWithList(Schema): + list_field = List(Nested(PetSchema)) + + spec.components.schema("SchemaWithList", schema=SchemaWithList) + + assert len(get_schemas(spec)) == 2 + + result = get_schemas(spec)["SchemaWithList"]["properties"]["list_field"] + assert result == {"items": build_ref(spec, "schema", "Pet"), "type": "array"} + + +class TestTimeDelta: + def test_timedelta_x_unit(self, spec): + class SchemaWithTimeDelta(Schema): + sec = TimeDelta("seconds") + day = TimeDelta("days") + + spec.components.schema("SchemaWithTimeDelta", schema=SchemaWithTimeDelta) + + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["sec"]["x-unit"] + == "seconds" + ) + assert ( + get_schemas(spec)["SchemaWithTimeDelta"]["properties"]["day"]["x-unit"] + == "days" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_common.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_common.py new file mode 100644 index 0000000000000000000000000000000000000000..b3cfa4d14e49db9796ecf66fa9e37b880aab7382 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_common.py @@ -0,0 +1,90 @@ +import pytest +from marshmallow import Schema, fields + +from apispec.ext.marshmallow.common import ( + get_fields, + get_unique_schema_name, + make_schema_key, +) + +from .schemas import PetSchema, SampleSchema + + +class TestMakeSchemaKey: + def test_raise_if_schema_class_passed(self): + with pytest.raises(TypeError, match="based on a Schema instance"): + make_schema_key(PetSchema) + + def test_same_schemas_instances_equal(self): + assert make_schema_key(PetSchema()) == make_schema_key(PetSchema()) + + @pytest.mark.parametrize("structure", (list, set)) + def test_same_schemas_instances_unhashable_modifiers_equal(self, structure): + modifier = [str(i) for i in range(1000)] + assert make_schema_key( + PetSchema(load_only=structure(modifier)) + ) == make_schema_key(PetSchema(load_only=structure(modifier[::-1]))) + + def test_different_schemas_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(SampleSchema()) + + def test_instances_with_different_modifiers_not_equal(self): + assert make_schema_key(PetSchema()) != make_schema_key(PetSchema(partial=True)) + + +class TestUniqueName: + def test_unique_name(self, spec): + properties = { + "id": {"type": "integer", "format": "int64"}, + "name": {"type": "string", "example": "doggie"}, + } + + name = get_unique_schema_name(spec.components, "Pet") + assert name == "Pet" + + spec.components.schema("Pet", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_1 = get_unique_schema_name(spec.components, "Pet") + assert name_1 == "Pet1" + + spec.components.schema("Pet1", properties=properties) + with pytest.warns( + UserWarning, match="Multiple schemas resolved to the name Pet" + ): + name_2 = get_unique_schema_name(spec.components, "Pet") + assert name_2 == "Pet2" + + +class TestGetFields: + @pytest.mark.parametrize("exclude_type", (tuple, list)) + @pytest.mark.parametrize("dump_only_type", (tuple, list)) + def test_get_fields_meta_exclude_dump_only_as_list_and_tuple( + self, exclude_type, dump_only_type + ): + class ExcludeSchema(Schema): + field1 = fields.Int() + field2 = fields.Int() + field3 = fields.Int() + field4 = fields.Int() + field5 = fields.Int() + + class Meta: + ordered = True + exclude = exclude_type(("field1", "field2")) + dump_only = dump_only_type(("field3", "field4")) + + assert list(get_fields(ExcludeSchema).keys()) == ["field3", "field4", "field5"] + assert list(get_fields(ExcludeSchema, exclude_dump_only=True).keys()) == [ + "field5" + ] + + # regression test for https://github.com/marshmallow-code/apispec/issues/673 + def test_schema_with_field_named_fields(self): + class TestSchema(Schema): + fields = fields.Int() + + schema_fields = get_fields(TestSchema) + assert list(schema_fields.keys()) == ["fields"] + assert isinstance(schema_fields["fields"], fields.Int) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_field.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_field.py new file mode 100644 index 0000000000000000000000000000000000000000..5beba1a765d46272fff400038618bd24fa4022c4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_field.py @@ -0,0 +1,664 @@ +import datetime as dt +import re +from enum import Enum + +import pytest +from marshmallow import Schema, fields, validate + +from .schemas import CategorySchema, CustomIntegerField, CustomList, CustomStringField +from .utils import build_ref, get_schemas + + +def test_field2choices_preserving_order(openapi): + choices = ["a", "b", "c", "aa", "0", "cc"] + field = fields.String(validate=validate.OneOf(choices)) + assert openapi.field2choices(field) == {"enum": choices} + + +@pytest.mark.parametrize( + ("FieldClass", "jsontype"), + [ + (fields.Integer, "integer"), + (fields.Float, "number"), + (fields.String, "string"), + (fields.Str, "string"), + (fields.Boolean, "boolean"), + (fields.Bool, "boolean"), + (fields.UUID, "string"), + (fields.DateTime, "string"), + (fields.Date, "string"), + (fields.Time, "string"), + (fields.TimeDelta, "integer"), + (fields.Email, "string"), + (fields.URL, "string"), + (fields.IP, "string"), + (fields.IPv4, "string"), + (fields.IPv6, "string"), + # Custom fields inherit types from their parents + (CustomStringField, "string"), + (CustomIntegerField, "integer"), + ], +) +def test_field2property_type(FieldClass, jsontype, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["type"] == jsontype + + +def test_field2property_no_type(spec_fixture): + field = fields.Raw() + res = spec_fixture.openapi.field2property(field) + assert "type" not in res + + +@pytest.mark.parametrize("ListClass", [fields.List, CustomList]) +def test_formatted_field_translates_to_array(ListClass, spec_fixture): + field = ListClass(fields.String) + res = spec_fixture.openapi.field2property(field) + assert res["type"] == "array" + assert res["items"] == spec_fixture.openapi.field2property(fields.String()) + + +@pytest.mark.parametrize( + ("FieldClass", "expected_format"), + [ + (fields.UUID, "uuid"), + (fields.DateTime, "date-time"), + (fields.Date, "date"), + (fields.Email, "email"), + (fields.URL, "url"), + (fields.IP, "ip"), + (fields.IPv4, "ipv4"), + (fields.IPv6, "ipv6"), + ], +) +def test_field2property_formats(FieldClass, expected_format, spec_fixture): + field = FieldClass() + res = spec_fixture.openapi.field2property(field) + assert res["format"] == expected_format + + +def test_field_with_description(spec_fixture): + field = fields.Str(metadata={"description": "a username"}) + res = spec_fixture.openapi.field2property(field) + assert res["description"] == "a username" + + +def test_field_with_load_default(spec_fixture): + field = fields.Str(dump_default="foo", load_default="bar") + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "bar" + + +def test_boolean_field_with_false_load_default(spec_fixture): + field = fields.Boolean(dump_default=None, load_default=False) + res = spec_fixture.openapi.field2property(field) + assert res["default"] is False + + +def test_datetime_field_with_load_default(spec_fixture): + field = fields.Date(load_default=dt.date(2014, 7, 18)) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == dt.date(2014, 7, 18).isoformat() + + +def test_field_with_load_default_callable(spec_fixture): + field = fields.Str(load_default=lambda: "dummy") + res = spec_fixture.openapi.field2property(field) + assert "default" not in res + + +def test_field_with_default(spec_fixture): + field = fields.Str(metadata={"default": "Manual default"}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == "Manual default" + + +def test_field_with_default_and_load_default(spec_fixture): + field = fields.Int(load_default=12, metadata={"default": 42}) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == 42 + + +def test_field_with_choices(spec_fixture): + field = fields.Str(validate=validate.OneOf(["freddie", "brian", "john"])) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john"} + + +def test_field_with_nullable_choices(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john"]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"freddie", "brian", "john", None} + + +def test_field_with_nullable_choices_returns_only_one_none(spec_fixture): + field = fields.Str( + validate=validate.OneOf(["freddie", "brian", "john", None]), allow_none=True + ) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["freddie", "brian", "john", None] + + +def test_field_with_equal(spec_fixture): + field = fields.Str(validate=validate.Equal("only choice")) + res = spec_fixture.openapi.field2property(field) + assert res["enum"] == ["only choice"] + + +def test_only_allows_valid_properties_in_metadata(spec_fixture): + field = fields.Str( + load_default="foo", + metadata={ + "description": "foo", + "not_valid": "lol", + "allOf": ["bar"], + "enum": ["red", "blue"], + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res["default"] == field.load_default + assert "description" in res + assert "enum" in res + assert "allOf" in res + assert "not_valid" not in res + + +def test_field_with_choices_multiple(spec_fixture): + field = fields.Str( + validate=[ + validate.OneOf(["freddie", "brian", "john"]), + validate.OneOf(["brian", "john", "roger"]), + ] + ) + res = spec_fixture.openapi.field2property(field) + assert set(res["enum"]) == {"brian", "john"} + + +def test_field_with_additional_metadata(spec_fixture): + field = fields.Str(metadata={"minLength": 6, "maxLength": 100}) + res = spec_fixture.openapi.field2property(field) + assert res["maxLength"] == 100 + assert res["minLength"] == 6 + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_allow_none(spec_fixture): + field = fields.Str(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert res["type"] == ["string", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +@pytest.mark.parametrize("field_class", [fields.Field, fields.Raw]) +def test_nullable_field_with_no_type(spec_fixture, field_class): + field = field_class(allow_none=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert res["x-nullable"] is True + elif spec_fixture.openapi.openapi_version.minor < 1: + assert res["nullable"] is True + else: + assert "nullable" not in res + assert "type" not in res + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable(spec_fixture): + class Child(Schema): + name = fields.Str() + + field = fields.Nested(Child, allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"$ref": "#/definitions/Child", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"type": "object", "nullable": True}, + {"$ref": "#/components/schemas/Child"}, + ] + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}] + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nested_nullable_with_metadata(spec_fixture): + # Regression test for https://github.com/marshmallow-code/apispec/issues/955 + class Child(Schema): + name = fields.Str() + + field = fields.Nested( + Child, + allow_none=True, + metadata={"description": "foo"}, + ) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == { + "allOf": [ + {"$ref": "#/definitions/Child"}, + ], + "x-nullable": True, + "description": "foo", + } + elif version.major == 3 and version.minor < 1: + assert res == { + "anyOf": [ + {"$ref": "#/components/schemas/Child"}, + {"type": "object", "nullable": True}, + ], + "description": "foo", + } + else: + assert res == { + "anyOf": [{"$ref": "#/components/schemas/Child"}, {"type": "null"}], + "description": "foo", + } + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_nullable_pluck(spec_fixture): + class Example(Schema): + name = fields.Str() + + field = fields.Pluck(Example, "name", allow_none=True) + res = spec_fixture.openapi.field2property(field) + version = spec_fixture.openapi.openapi_version + if version.major < 3: + assert res == {"type": "string", "x-nullable": True} + elif version.major == 3 and version.minor < 1: + assert res == {"type": "string", "nullable": True} + else: + assert res == {"type": ["string", "null"]} + + +def test_field_with_dump_only(spec_fixture): + field = fields.Str(dump_only=True) + res = spec_fixture.openapi.field2property(field) + assert res["readOnly"] is True + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field_with_load_only(spec_fixture): + field = fields.Str(load_only=True) + res = spec_fixture.openapi.field2property(field) + if spec_fixture.openapi.openapi_version.major < 3: + assert "writeOnly" not in res + else: + assert res["writeOnly"] is True + + +def test_field_with_range_no_type(spec_fixture): + field = fields.Raw(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert "type" not in res + + +@pytest.mark.parametrize("field", (fields.Float, fields.Integer)) +def test_field_with_range_string_type(spec_fixture, field): + field = field(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert isinstance(res["type"], str) + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_with_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["integer", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["minimum"] == 1 + assert res["maximum"] == 10 + assert res["type"] == ["integer", "null"] + + +@pytest.mark.parametrize("spec_fixture", ("3.1.0",), indirect=True) +def test_field_with_range_type_list_without_number(spec_fixture): + class NullableInteger(fields.Field): + """Nullable integer""" + + spec_fixture.openapi.map_to_openapi_type(NullableInteger, ["string", "null"], None) + + field = NullableInteger(validate=validate.Range(min=1, max=10)) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == 1 + assert res["x-maximum"] == 10 + assert res["type"] == ["string", "null"] + + +def test_field_with_range_datetime_type(spec_fixture): + field = fields.DateTime( + validate=validate.Range( + min=dt.datetime(1900, 1, 1), + max=dt.datetime(2000, 1, 1), + ) + ) + res = spec_fixture.openapi.field2property(field) + assert res["x-minimum"] == "1900-01-01T00:00:00" + assert res["x-maximum"] == "2000-01-01T00:00:00" + assert isinstance(res["type"], str) + + +def test_field_with_str_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(regex_str)) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_pattern_obj_regex(spec_fixture): + regex_str = "^[a-zA-Z0-9]$" + field = fields.Str(validate=validate.Regexp(re.compile(regex_str))) + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == regex_str + + +def test_field_with_no_pattern(spec_fixture): + field = fields.Str() + ret = spec_fixture.openapi.field2property(field) + assert "pattern" not in ret + + +def test_field_with_multiple_patterns(recwarn, spec_fixture): + regex_validators = [validate.Regexp("winner"), validate.Regexp("loser")] + field = fields.Str(validate=regex_validators) + with pytest.warns(UserWarning, match="More than one regex validator"): + ret = spec_fixture.openapi.field2property(field) + assert ret["pattern"] == "winner" + + +def test_enum_symbol_field(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum) + ret = spec_fixture.openapi.field2property(field) + assert ret["type"] == "string" + assert ret["enum"] == ["one", "two"] + + +@pytest.mark.parametrize("by_value", [fields.Integer, True]) +def test_enum_value_field(spec_fixture, by_value): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, by_value=by_value) + ret = spec_fixture.openapi.field2property(field) + if by_value is True: + assert "type" not in ret + else: + assert ret["type"] == "integer" + assert ret["enum"] == [1, 2] + + +def test_nullable_enum(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +def test_nullable_enum_returns_only_one_none(spec_fixture): + class MyEnum(Enum): + one = 1 + two = 2 + three = None + + field = fields.Enum(MyEnum, allow_none=True, by_value=True) + ret = spec_fixture.openapi.field2property(field) + assert ret["enum"] == [1, 2, None] + + +@pytest.mark.parametrize("spec_fixture", ("2.0", "3.0.0", "3.1.0"), indirect=True) +def test_field2property_nested_spec_metadatas(spec_fixture): + class Child(Schema): + name = fields.Str() + + category = fields.Nested( + Child, + metadata={ + "description": "A category", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + result = spec_fixture.openapi.field2property(category) + version = spec_fixture.openapi.openapi_version + if version.major < 3 or version.minor < 1: + assert result == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Child")], + "description": "A category", + "x-extension": "A great extension", + } + else: + assert result == { + **build_ref(spec_fixture.spec, "schema", "Child"), + "description": "A category", + "x-extension": "A great extension", + } + + +def test_field2property_nested_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema) + assert spec_fixture.openapi.field2property(category) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + +def test_field2property_nested_many_spec(spec_fixture): + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + category = fields.Nested(CategorySchema, many=True) + ret = spec_fixture.openapi.field2property(category) + assert ret["type"] == "array" + assert ret["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_ref(spec_fixture): + category = fields.Nested(CategorySchema) + ref = spec_fixture.openapi.field2property(category) + assert ref == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_field2property_nested_many(spec_fixture): + categories = fields.Nested(CategorySchema, many=True) + res = spec_fixture.openapi.field2property(categories) + assert res["type"] == "array" + assert res["items"] == build_ref(spec_fixture.spec, "schema", "Category") + + +def test_nested_field_with_property(spec_fixture): + category_1 = fields.Nested(CategorySchema) + category_2 = fields.Nested(CategorySchema, dump_only=True) + category_3 = fields.Nested(CategorySchema, many=True) + category_4 = fields.Nested(CategorySchema, many=True, dump_only=True) + spec_fixture.spec.components.schema("Category", schema=CategorySchema) + + assert spec_fixture.openapi.field2property(category_1) == build_ref( + spec_fixture.spec, "schema", "Category" + ) + assert spec_fixture.openapi.field2property(category_2) == { + "allOf": [build_ref(spec_fixture.spec, "schema", "Category")], + "readOnly": True, + } + assert spec_fixture.openapi.field2property(category_3) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "type": "array", + } + assert spec_fixture.openapi.field2property(category_4) == { + "items": build_ref(spec_fixture.spec, "schema", "Category"), + "readOnly": True, + "type": "array", + } + + +def test_datetime2property_iso(spec_fixture): + field = fields.DateTime(format="iso") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": "date-time", + } + + +def test_datetime2property_rfc(spec_fixture): + field = fields.DateTime(format="rfc") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "example": "Wed, 02 Oct 2002 13:00:00 GMT", + "pattern": r"((Mon|Tue|Wed|Thu|Fri|Sat|Sun), ){0,1}\d{2} " + + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} " + + r"(UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|(Z|A|M|N)|(\+|-)\d{4})", + } + + +def test_datetime2property_timestamp(spec_fixture): + field = fields.DateTime(format="timestamp") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451245.596", + } + + +def test_datetime2property_timestamp_ms(spec_fixture): + field = fields.DateTime(format="timestamp_ms") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "number", + "format": "float", + "min": "0", + "example": "1676451277514.654", + } + + +def test_datetime2property_custom_format(spec_fixture): + field = fields.DateTime( + format="%d-%m%Y %H:%M:%S", + metadata={ + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$" + }, + ) + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": r"^((?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))(Z|[\+-]\d{2}:\d{2})?)$", + } + + +def test_datetime2property_custom_format_missing_regex(spec_fixture): + field = fields.DateTime(format="%d-%m%Y %H:%M:%S") + res = spec_fixture.openapi.field2property(field) + assert res == { + "type": "string", + "format": None, + "pattern": None, + } + + +class TestField2PropertyPluck: + @pytest.fixture(autouse=True) + def _setup(self, spec_fixture): + self.field2property = spec_fixture.openapi.field2property + + self.spec = spec_fixture.spec + self.spec.components.schema("Category", schema=CategorySchema) + self.unplucked = get_schemas(self.spec)["Category"]["properties"]["breed"] + + def test_spec(self, spec_fixture): + breed = fields.Pluck(CategorySchema, "breed") + assert self.field2property(breed) == self.unplucked + + def test_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", dump_only=True) + assert self.field2property(breed) == {**self.unplucked, "readOnly": True} + + def test_metadata(self): + breed = fields.Pluck( + CategorySchema, + "breed", + metadata={ + "description": "Category breed", + "invalid_property": "not in the result", + "x_extension": "A great extension", + }, + ) + assert self.field2property(breed) == { + **self.unplucked, + "description": "Category breed", + "x-extension": "A great extension", + } + + def test_many(self): + breed = fields.Pluck(CategorySchema, "breed", many=True) + assert self.field2property(breed) == {"type": "array", "items": self.unplucked} + + def test_many_with_property(self): + breed = fields.Pluck(CategorySchema, "breed", many=True, dump_only=True) + assert self.field2property(breed) == { + "items": self.unplucked, + "type": "array", + "readOnly": True, + } + + +def test_custom_properties_for_custom_fields(spec_fixture): + def custom_string2properties(self, field, **kwargs): + ret = {} + if isinstance(field, CustomStringField): + if self.openapi_version.major == 2: + ret["x-customString"] = True + else: + ret["x-customString"] = False + return ret + + spec_fixture.marshmallow_plugin.converter.add_attribute_function( + custom_string2properties + ) + properties = spec_fixture.marshmallow_plugin.converter.field2property( + CustomStringField() + ) + assert properties["x-customString"] == ( + spec_fixture.openapi.openapi_version.major == 2 + ) + + +def test_field2property_with_non_string_metadata_keys(spec_fixture): + class _DesertSentinel: + pass + + field = fields.Boolean(metadata={"description": "A description"}) + field.metadata[_DesertSentinel()] = "to be ignored" + result = spec_fixture.openapi.field2property(field) + assert result == {"description": "A description", "type": "boolean"} diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_openapi.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_openapi.py new file mode 100644 index 0000000000000000000000000000000000000000..55ca8d35d8328b82118a4b3918c98b4e3aa21505 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_ext_marshmallow_openapi.py @@ -0,0 +1,685 @@ +from datetime import datetime + +import pytest +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from packaging.version import Version + +from apispec import APISpec, exceptions +from apispec.ext.marshmallow import MarshmallowPlugin, OpenAPIConverter + +from .schemas import CustomList, CustomStringField +from .utils import build_ref, get_schemas, validate_spec + + +class TestMarshmallowFieldToOpenAPI: + def test_fields_with_load_default_load(self, openapi): + class MySchema(Schema): + field = fields.Str(dump_default="foo", load_default="bar") + + res = openapi.schema2parameters(MySchema, location="query") + if openapi.openapi_version.major < 3: + assert res[0]["default"] == "bar" + else: + assert res[0]["schema"]["default"] == "bar" + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_fields_default_location_mapping_if_schema_many(self, openapi): + class ExampleSchema(Schema): + id = fields.Int() + + schema = ExampleSchema(many=True) + res = openapi.schema2parameters(schema=schema, location="json") + assert res[0]["in"] == "body" + + def test_fields_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str(dump_only=True) + + res = openapi.schema2parameters(schema=UserSchema(), location="query") + assert len(res) == 0 + + class UserSchema2(Schema): + name = fields.Str() + + class Meta: + dump_only = ("name",) + + res = openapi.schema2parameters(schema=UserSchema2(), location="query") + assert len(res) == 0 + + +class TestMarshmallowSchemaToModelDefinition: + def test_schema2jsonschema_with_explicit_fields(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + email = fields.Email(metadata={"description": "email address of the user"}) + name = fields.Str() + + class Meta: + title = "User" + + res = openapi.schema2jsonschema(UserSchema) + assert res["title"] == "User" + assert res["type"] == "object" + props = res["properties"] + assert props["_id"]["type"] == "integer" + assert props["email"]["type"] == "string" + assert props["email"]["format"] == "email" + assert props["email"]["description"] == "email address of the user" + + def test_schema2jsonschema_override_name(self, openapi): + class ExampleSchema(Schema): + _id = fields.Int(data_key="id") + _global = fields.Int(data_key="global") + + class Meta: + exclude = ("_global",) + + res = openapi.schema2jsonschema(ExampleSchema) + assert res["type"] == "object" + props = res["properties"] + # `_id` renamed to `id` + assert "_id" not in props and props["id"]["type"] == "integer" + # `_global` excluded correctly + assert "_global" not in props and "global" not in props + + def test_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert res["required"] == ["drummer"] + + def test_partial(self, openapi): + class BandSchema(Schema): + drummer = fields.Str(required=True) + bassist = fields.Str(required=True) + + res = openapi.schema2jsonschema(BandSchema(partial=True)) + assert "required" not in res + + res = openapi.schema2jsonschema(BandSchema(partial=("drummer",))) + assert res["required"] == ["bassist"] + + def test_no_required_fields(self, openapi): + class BandSchema(Schema): + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(BandSchema) + assert "required" not in res + + def test_title_and_description_may_be_added(self, openapi): + class UserSchema(Schema): + class Meta: + title = "User" + description = "A registered user" + + res = openapi.schema2jsonschema(UserSchema) + assert res["description"] == "A registered user" + assert res["title"] == "User" + + def test_excluded_fields(self, openapi): + class WhiteStripesSchema(Schema): + class Meta: + exclude = ("bassist",) + + guitarist = fields.Str() + drummer = fields.Str() + bassist = fields.Str() + + res = openapi.schema2jsonschema(WhiteStripesSchema) + assert set(res["properties"].keys()) == {"guitarist", "drummer"} + + def test_unknown_values_disallow(self, openapi): + class UnknownRaiseSchema(Schema): + class Meta: + unknown = RAISE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownRaiseSchema) + assert res["additionalProperties"] is False + + def test_unknown_values_allow(self, openapi): + class UnknownIncludeSchema(Schema): + class Meta: + unknown = INCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownIncludeSchema) + assert res["additionalProperties"] is True + + def test_unknown_values_ignore(self, openapi): + class UnknownExcludeSchema(Schema): + class Meta: + unknown = EXCLUDE + + first = fields.Str() + + res = openapi.schema2jsonschema(UnknownExcludeSchema) + assert "additionalProperties" not in res + + def test_only_explicitly_declared_fields_are_translated(self, openapi): + class UserSchema(Schema): + _id = fields.Int() + + class Meta: + title = "User" + fields = ("_id", "email") + + with pytest.warns( + UserWarning, + match="Only explicitly-declared fields will be included in the Schema Object.", + ): + res = openapi.schema2jsonschema(UserSchema) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + assert "email" not in props + + def test_observed_field_name_for_required_field(self, openapi): + fields_dict = {"user_id": fields.Int(data_key="id", required=True)} + res = openapi.fields2jsonschema(fields_dict) + assert res["required"] == ["id"] + + @pytest.mark.parametrize("many", (True, False)) + def test_schema_instance_inspection(self, openapi, many): + class UserSchema(Schema): + _id = fields.Int() + + res = openapi.schema2jsonschema(UserSchema(many=many)) + assert res["type"] == "object" + props = res["properties"] + assert "_id" in props + + def test_raises_error_if_no_declared_fields(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class TestMarshmallowSchemaToParameters: + def test_custom_properties_for_custom_fields(self, spec_fixture): + class DelimitedList(fields.List): + """Delimited list field""" + + def delimited_list2param(self, field: fields.Field, **kwargs) -> dict: + ret: dict = {} + if isinstance(field, DelimitedList): + if self.openapi_version.major < 3: + ret["collectionFormat"] = "csv" + else: + ret["explode"] = False + ret["style"] = "form" + return ret + + spec_fixture.marshmallow_plugin.converter.add_parameter_attribute_function( + delimited_list2param + ) + + class MySchema(Schema): + delimited_list = DelimitedList(fields.Int) + + param = spec_fixture.marshmallow_plugin.converter.schema2parameters( + MySchema(), location="query" + )[0] + + if spec_fixture.openapi.openapi_version.major < 3: + assert param["collectionFormat"] == "csv" + else: + assert param["explode"] is False + assert param["style"] == "form" + + def test_field_required(self, openapi): + field = fields.Str(required=True) + res = openapi._field2parameter(field, name="field", location="query") + assert res["required"] is True + + def test_field_deprecated(self, openapi): + field = fields.Str(metadata={"deprecated": True}) + res = openapi._field2parameter(field, name="field", location="query") + assert res["deprecated"] is True + + def test_schema_partial(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=True), location="query" + ) + + param = res_nodump[0] + assert param["required"] is False + + def test_schema_partial_list(self, openapi): + class UserSchema(Schema): + field = fields.Str(required=True) + partial_field = fields.Str(required=True) + + res_nodump = openapi.schema2parameters( + UserSchema(partial=("partial_field",)), location="query" + ) + + param = next(p for p in res_nodump if p["name"] == "field") + assert param["required"] is True + param = next(p for p in res_nodump if p["name"] == "partial_field") + assert param["required"] is False + + @pytest.mark.parametrize("ListClass", [fields.List, CustomList]) + def test_field_list(self, ListClass, openapi): + field = ListClass(fields.Str) + res = openapi._field2parameter(field, name="field", location="query") + assert res["in"] == "query" + if openapi.openapi_version.major < 3: + assert res["type"] == "array" + assert res["items"]["type"] == "string" + assert res["collectionFormat"] == "multi" + else: + assert res["schema"]["type"] == "array" + assert res["schema"]["items"]["type"] == "string" + assert res["style"] == "form" + assert res["explode"] is True + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"] == {"$ref": "#/definitions/User"} + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_with_dump_only(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email(dump_only=True) + + res_nodump = openapi.schema2parameters(UserSchema, location="body") + assert len(res_nodump) == 1 + param = res_nodump[0] + assert param["in"] == "body" + assert param["schema"] == build_ref(openapi.spec, "schema", "User") + + # json/body is invalid for OpenAPI 3 + @pytest.mark.parametrize("openapi", ("2.0",), indirect=True) + def test_schema_body_many(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(many=True), location="body") + assert len(res) == 1 + param = res[0] + assert param["in"] == "body" + assert param["schema"]["type"] == "array" + assert param["schema"]["items"] == {"$ref": "#/definitions/User"} + + def test_schema_query(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(UserSchema(), location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_schema_query_instance_many_should_raise_exception(self, openapi): + class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + + with pytest.raises(AssertionError): + openapi.schema2parameters(UserSchema(many=True), location="query") + + def test_fields_query(self, openapi): + class MySchema(Schema): + name = fields.Str() + email = fields.Email() + + res = openapi.schema2parameters(MySchema, location="query") + assert len(res) == 2 + res.sort(key=lambda param: param["name"]) + assert res[0]["name"] == "email" + assert res[0]["in"] == "query" + assert res[1]["name"] == "name" + assert res[1]["in"] == "query" + + def test_raises_error_if_not_a_schema(self, openapi): + class NotASchema: + pass + + expected_error = ( + f"{NotASchema!r} is neither a Schema class nor a Schema instance." + ) + with pytest.raises(ValueError, match=expected_error): + openapi.schema2jsonschema(NotASchema) + + +class CategorySchema(Schema): + id = fields.Int() + name = fields.Str(required=True) + breed = fields.Str(dump_only=True) + + +class PageSchema(Schema): + offset = fields.Int() + limit = fields.Int() + + +class PetSchema(Schema): + category = fields.Nested(CategorySchema, many=True) + name = fields.Str() + + +class TestNesting: + def test_schema2jsonschema_with_nested_fields(self, spec_fixture): + res = spec_fixture.openapi.schema2jsonschema(PetSchema) + props = res["properties"] + + assert props["category"]["items"] == build_ref( + spec_fixture.spec, "schema", "Category" + ) + + @pytest.mark.parametrize("modifier", ("only", "exclude")) + def test_schema2jsonschema_with_nested_fields_only_exclude( + self, spec_fixture, modifier + ): + class Child(Schema): + i = fields.Int() + j = fields.Int() + + class Parent(Schema): + child = fields.Nested(Child, **{modifier: ("i",)}) + + spec_fixture.openapi.schema2jsonschema(Parent) + props = get_schemas(spec_fixture.spec)["Child"]["properties"] + assert ("i" in props) == (modifier == "only") + assert ("j" not in props) == (modifier == "only") + + def test_schema2jsonschema_with_plucked_field(self, spec_fixture): + class PetSchema(Schema): + breed = fields.Pluck(CategorySchema, "breed") + + category_schema = spec_fixture.openapi.schema2jsonschema(CategorySchema) + pet_schema = spec_fixture.openapi.schema2jsonschema(PetSchema) + assert ( + pet_schema["properties"]["breed"] == category_schema["properties"]["breed"] + ) + + def test_schema2jsonschema_with_nested_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["id"].required = True + + class PetSchema(Schema): + category = fields.Nested(category_schema, many=True) + name = fields.Str() + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec) + + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + category_schema + ) + assert set(props["Category"]["required"]) == {"id", "name"} + + props["Category"]["required"] = ["name"] + assert props["Category"] == spec_fixture.openapi.schema2jsonschema( + CategorySchema + ) + + def test_schema2jsonschema_with_plucked_fields_with_adhoc_changes( + self, spec_fixture + ): + category_schema = CategorySchema() + category_schema.fields["breed"].dump_only = True + + class PetSchema(Schema): + breed = fields.Pluck(category_schema, "breed", many=True) + + spec_fixture.spec.components.schema("Pet", schema=PetSchema) + props = get_schemas(spec_fixture.spec)["Pet"]["properties"] + + assert props["breed"]["items"]["readOnly"] is True + + def test_schema2jsonschema_with_nested_excluded_fields(self, spec): + category_schema = CategorySchema(exclude=("breed",)) + + class PetSchema(Schema): + category = fields.Nested(category_schema) + + spec.components.schema("Pet", schema=PetSchema) + + category_props = get_schemas(spec)["Category"]["properties"] + assert "breed" not in category_props + + +def test_openapi_tools_validate_v2(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="2.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", {"discriminator": "name"}, schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "type": "string"}, + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": {200: {"schema": PetSchema, "description": "A pet"}}, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "type": "string", + } + ] + + openapi.schema2parameters(CategorySchema, location="body") + ), + "responses": {201: {"schema": PetSchema, "description": "A pet"}}, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_tools_validate_v3(): + ma_plugin = MarshmallowPlugin() + spec = APISpec( + title="Pets", version="0.1", plugins=(ma_plugin,), openapi_version="3.0.0" + ) + openapi = ma_plugin.converter + assert openapi is not None + + spec.components.schema("Category", schema=CategorySchema) + spec.components.schema("Pet", schema=PetSchema) + + spec.path( + view=None, + path="/category/{category_id}", + operations={ + "get": { + "parameters": [ + {"name": "q", "in": "query", "schema": {"type": "string"}}, + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + }, + openapi._field2parameter( + field=fields.List( + fields.Str(), + validate=validate.OneOf(["freddie", "roger"]), + ), + location="query", + name="body", + ), + ] + + openapi.schema2parameters(PageSchema, location="query"), + "responses": { + 200: { + "description": "success", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + "post": { + "parameters": ( + [ + { + "name": "category_id", + "in": "path", + "required": True, + "schema": {"type": "string"}, + } + ] + ), + "requestBody": { + "content": {"application/json": {"schema": CategorySchema}} + }, + "responses": { + 201: { + "description": "created", + "content": {"application/json": {"schema": PetSchema}}, + } + }, + }, + }, + ) + try: + validate_spec(spec) + except exceptions.OpenAPIError as error: + pytest.fail(str(error)) + + +def test_openapi_converter_openapi_version_types(): + spec = APISpec(title="Pets", version="0.1", openapi_version="2.0") + converter_with_version = OpenAPIConverter(Version("3.1"), None, spec) + converter_with_str_version = OpenAPIConverter("3.1", None, spec) + assert ( + converter_with_version.openapi_version + == converter_with_str_version.openapi_version + ) + + +class TestFieldValidation: + class ValidationSchema(Schema): + id = fields.Int(dump_only=True) + range = fields.Int(validate=validate.Range(min=1, max=10)) + range_no_upper = fields.Float(validate=validate.Range(min=1)) + multiple_ranges = fields.Int( + validate=[ + validate.Range(min=1), + validate.Range(min=3), + validate.Range(max=10), + validate.Range(max=7), + ] + ) + list_length = fields.List(fields.Str, validate=validate.Length(min=1, max=10)) + custom_list_length = CustomList( + fields.Str, validate=validate.Length(min=1, max=10) + ) + string_length = fields.Str(validate=validate.Length(min=1, max=10)) + custom_field_length = CustomStringField(validate=validate.Length(min=1, max=10)) + multiple_lengths = fields.Str( + validate=[ + validate.Length(min=1), + validate.Length(min=3), + validate.Length(max=10), + validate.Length(max=7), + ] + ) + equal_length = fields.Str( + validate=[validate.Length(equal=5), validate.Length(min=1, max=10)] + ) + date_range = fields.DateTime( + validate=validate.Range( + min=datetime(1900, 1, 1), + ) + ) + + @pytest.mark.parametrize( + ("field", "properties"), + [ + ("range", {"minimum": 1, "maximum": 10}), + ("range_no_upper", {"minimum": 1}), + ("multiple_ranges", {"minimum": 3, "maximum": 7}), + ("list_length", {"minItems": 1, "maxItems": 10}), + ("custom_list_length", {"minItems": 1, "maxItems": 10}), + ("string_length", {"minLength": 1, "maxLength": 10}), + ("custom_field_length", {"minLength": 1, "maxLength": 10}), + ("multiple_lengths", {"minLength": 3, "maxLength": 7}), + ("equal_length", {"minLength": 5, "maxLength": 5}), + ("date_range", {"x-minimum": "1900-01-01T00:00:00"}), + ], + ) + def test_properties(self, field, properties, spec): + spec.components.schema("Validation", schema=self.ValidationSchema) + result = get_schemas(spec)["Validation"]["properties"][field] + + for attr, expected_value in properties.items(): + assert attr in result + assert result[attr] == expected_value diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..8a9f4362456ebe877fe513d1d353d045eb66627e --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_utils.py @@ -0,0 +1,24 @@ +from apispec import utils + + +def test_build_reference(): + assert utils.build_reference("schema", 2, "Test") == {"$ref": "#/definitions/Test"} + assert utils.build_reference("parameter", 2, "Test") == { + "$ref": "#/parameters/Test" + } + assert utils.build_reference("response", 2, "Test") == {"$ref": "#/responses/Test"} + assert utils.build_reference("security_scheme", 2, "Test") == { + "$ref": "#/securityDefinitions/Test" + } + assert utils.build_reference("schema", 3, "Test") == { + "$ref": "#/components/schemas/Test" + } + assert utils.build_reference("parameter", 3, "Test") == { + "$ref": "#/components/parameters/Test" + } + assert utils.build_reference("response", 3, "Test") == { + "$ref": "#/components/responses/Test" + } + assert utils.build_reference("security_scheme", 3, "Test") == { + "$ref": "#/components/securitySchemes/Test" + } diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_yaml_utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_yaml_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd28c9dedebac5d88dd057d538ccb2ae3f792 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/test_yaml_utils.py @@ -0,0 +1,47 @@ +import pytest + +from apispec import yaml_utils + + +def test_load_yaml_from_docstring(): + def f(): + """ + Foo + bar + baz quux + + --- + herp: 1 + derp: 2 + """ + + result = yaml_utils.load_yaml_from_docstring(f.__doc__) + assert result == {"herp": 1, "derp": 2} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_yaml_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_yaml_from_docstring(docstring) == {} + + +@pytest.mark.parametrize("docstring", (None, "", "---")) +def test_load_operations_from_docstring_empty_docstring(docstring): + assert yaml_utils.load_operations_from_docstring(docstring) == {} + + +def test_dict_to_yaml_unicode(): + assert yaml_utils.dict_to_yaml({"가": "나"}) == '"\\uAC00": "\\uB098"\n' + assert yaml_utils.dict_to_yaml({"가": "나"}, {"allow_unicode": True}) == "가: 나\n" + + +def test_dict_to_yaml_keys_are_not_sorted_by_default(): + assert yaml_utils.dict_to_yaml({"herp": 1, "derp": 2}) == "herp: 1\nderp: 2\n" + + +def test_dict_to_yaml_keys_can_be_sorted_with_yaml_dump_kwargs(): + assert ( + yaml_utils.dict_to_yaml( + {"herp": 1, "derp": 2}, yaml_dump_kwargs={"sort_keys": True} + ) + == "derp: 2\nherp: 1\n" + ) diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/utils.py b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..3f5392ca986ba01536b4ee956f556b24acdd8ec4 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tests/utils.py @@ -0,0 +1,65 @@ +"""Utilities to get elements of generated spec""" + +import openapi_spec_validator +from openapi_spec_validator.exceptions import OpenAPISpecValidatorError + +from apispec import exceptions +from apispec.core import APISpec +from apispec.utils import build_reference + + +def get_schemas(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["definitions"] + return spec.to_dict()["components"]["schemas"] + + +def get_responses(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["responses"] + return spec.to_dict()["components"]["responses"] + + +def get_parameters(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["parameters"] + return spec.to_dict()["components"]["parameters"] + + +def get_headers(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["headers"] + return spec.to_dict()["components"]["headers"] + + +def get_examples(spec): + return spec.to_dict()["components"]["examples"] + + +def get_security_schemes(spec): + if spec.openapi_version.major < 3: + return spec.to_dict()["securityDefinitions"] + return spec.to_dict()["components"]["securitySchemes"] + + +def get_paths(spec): + return spec.to_dict()["paths"] + + +def build_ref(spec, component_type, obj): + return build_reference(component_type, spec.openapi_version.major, obj) + + +def validate_spec(spec: APISpec) -> bool: + """Validate the output of an :class:`APISpec` object against the + OpenAPI specification. + + :raise: apispec.exceptions.OpenAPIError if validation fails. + """ + try: + # Coerce to dict to satisfy Pyright + openapi_spec_validator.validate(dict(spec.to_dict())) + except OpenAPISpecValidatorError as err: + raise exceptions.OpenAPIError(*err.args) from err + else: + return True diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tox.ini b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..9beedcb0506b9d96fafcf69594a08f3039cc8e17 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/tests/trusted/tox.ini @@ -0,0 +1,34 @@ +[tox] +envlist= + lint + py{39,310,311,312,313}-marshmallow3 + py313-marshmallowdev + docs + +[testenv] +extras = tests +deps = + marshmallow3: marshmallow>=3.10.0,<4.0.0 + marshmallowdev: https://github.com/marshmallow-code/marshmallow/archive/dev.tar.gz +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/apispec --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f567f18c64cbcbe96ab4f9e943ef8d670a6d709 --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/first-hunk-only.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/apispec/ext/marshmallow/common.py b/src/apispec/ext/marshmallow/common.py +index 3aa1b1f1bd545fc148d9a7fbdf690c2ac93e7e25..e5373771ab017e6b7dc138515139ab992c19cfe0 100644 +--- a/src/apispec/ext/marshmallow/common.py ++++ b/src/apispec/ext/marshmallow/common.py +@@ -22,11 +22,11 @@ + :param type|Schema|str schema: instance, class or class name of marshmallow.Schema + :return: schema instance of given schema (instance or class) + """ ++ if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): ++ return schema() + if isinstance(schema, marshmallow.Schema): + return schema +- if isinstance(schema, type) and issubclass(schema, marshmallow.Schema): +- return marshmallow.class_registry.get_class(schema.__name__)() +- return marshmallow.class_registry.get_class(schema) ++ return marshmallow.class_registry.get_class(schema)() + + + def resolve_schema_cls( +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/original-bug.sh b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/openenv.json b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__apispec.8b421526.combine_module__07okceme/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..2ce9b5de917ed50108cdd171eb116ee2cd46acf7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/adapter.json @@ -0,0 +1,138 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "checker_revision": { + "new_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "old_checker_sha256": "ce5f5ada4c63ab61c57177833687df68fcfe04df971699cb3e6ceada5722d2ed", + "old_plan_sha256": "77afa65138d2a166bac571d0b8f6c734af9bec6030739cd7c9e4bf19260ac432", + "old_task_digest": "7f5527b46753cca70b9e61b79e5003772defdf8d67ca7c969a1446c204c7f81e", + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_grader_sha256": "48d05896ed5af21d9b8ab20e1b3470a370ab635d1c0c6ebf4e8851761c184532", + "runtime_qualified": false, + "source_tests_or_panels_changed": false, + "version": "matched-failure-precedence-v2" + }, + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "7fbe638ee0099ab650c8abd4d5ed49136320a5d718368d7792c5524b3abebcf8", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "3617d680c01cae3e7933d4c4ffaa782333c768aaa572122e3e0161052916cac6", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "b31157ee9a73850046f5c489e1f88bd4378b4f08f56c454de8f12cee81dde1b3", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "56000b367f872b6caee4e52684b278e75daa2f44", + "source_completion_sha256": "69e6b6a63cf81611926a45eaf26c87a97607456ebd295f8d8825fda3d389e427", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "15c7d5e12db384a264526084c76bedf1cee7f20f7af20288cd999066952c98a7", + "is_fork": true, + "learner_path": "tasks/acb494821d07032059610493/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/56000b367f872b6caee4e52684b278e75daa2f44/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4d717b39b01b7bfdbe3d4dc33bffe7b808c902bacbeccecbbb0157c248302729", + "provenance_path": "tasks/acb494821d07032059610493/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "56000b367f872b6caee4e52684b278e75daa2f44", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "43906043b3f6c2576d054b19c0f0ce6584177186", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "task_sha256": "dacdcd6fcd50c3b10c3555a098f80de7b0eb5a17ba07b78c139bb10249b86ea9", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4e588e0cfd0307f8c7b231d9a16053ce604f055e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/instruction.md @@ -0,0 +1,41 @@ +URL validator fails with UnboundLocalError when validating URLs + +#### Description + +The URL validator is throwing an `UnboundLocalError: local variable 'key' referenced before assignment` when trying to validate any URL. This affects both absolute and relative URL validation. + +#### Steps/Code to Reproduce + +```python +from marshmallow import validate + +# This should work but throws UnboundLocalError +validator = validate.URL() +validator('http://example.org') +``` + +```python +from marshmallow import validate + +# Also fails for relative URLs +validator = validate.URL(relative=True, absolute=False) +validator('/foo/bar') +``` + +The error occurs immediately when calling the validator with any input. + +#### Expected Behavior + +The URL validator should successfully validate valid URLs and raise ValidationError for invalid ones, not UnboundLocalError. + +#### Actual Behavior + +``` +UnboundLocalError: local variable 'key' referenced before assignment +``` + +This affects all URL validation functionality in marshmallow. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..dbbe039b02a1db0557b974f6f28152f8a22832db --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/metadata.json @@ -0,0 +1,1409 @@ +{ + "all_runtime_and_training_flags": false, + "checker_revision": { + "new_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "old_checker_sha256": "ce5f5ada4c63ab61c57177833687df68fcfe04df971699cb3e6ceada5722d2ed", + "old_plan_sha256": "77afa65138d2a166bac571d0b8f6c734af9bec6030739cd7c9e4bf19260ac432", + "old_task_digest": "7f5527b46753cca70b9e61b79e5003772defdf8d67ca7c969a1446c204c7f81e", + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_grader_sha256": "48d05896ed5af21d9b8ab20e1b3470a370ab635d1c0c6ebf4e8851761c184532", + "runtime_qualified": false, + "source_tests_or_panels_changed": false, + "version": "matched-failure-precedence-v2" + }, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "43906043b3f6c2576d054b19c0f0ce6584177186", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "56000b367f872b6caee4e52684b278e75daa2f44" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_options.py", + "tests/test_schema.py", + "tests/test_validate.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/validate.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2205686, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "15c7d5e12db384a264526084c76bedf1cee7f20f7af20288cd999066952c98a7", + "is_fork": true, + "learner_path": "tasks/acb494821d07032059610493/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/56000b367f872b6caee4e52684b278e75daa2f44/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4d717b39b01b7bfdbe3d4dc33bffe7b808c902bacbeccecbbb0157c248302729", + "provenance_path": "tasks/acb494821d07032059610493/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "56000b367f872b6caee4e52684b278e75daa2f44", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "43906043b3f6c2576d054b19c0f0ce6584177186", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "task_sha256": "dacdcd6fcd50c3b10c3555a098f80de7b0eb5a17ba07b78c139bb10249b86ea9", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..a6fe7c8f6ba9b9f0f25f6c5c21ea9f21ba4e13c4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "7fbe638ee0099ab650c8abd4d5ed49136320a5d718368d7792c5524b3abebcf8", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/56000b367f872b6caee4e52684b278e75daa2f44/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "69e6b6a63cf81611926a45eaf26c87a97607456ebd295f8d8825fda3d389e427", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "34bbec2fd9a860dbf205c53eeca99ca980912c601062042d8db0bab88779f5ea", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "15c7d5e12db384a264526084c76bedf1cee7f20f7af20288cd999066952c98a7", + "is_fork": true, + "learner_path": "tasks/acb494821d07032059610493/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/56000b367f872b6caee4e52684b278e75daa2f44/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4d717b39b01b7bfdbe3d4dc33bffe7b808c902bacbeccecbbb0157c248302729", + "provenance_path": "tasks/acb494821d07032059610493/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "56000b367f872b6caee4e52684b278e75daa2f44", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "43906043b3f6c2576d054b19c0f0ce6584177186", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto", + "task_sha256": "dacdcd6fcd50c3b10c3555a098f80de7b0eb5a17ba07b78c139bb10249b86ea9", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..5477978af2e0fb6077092add5612949dfe331b73 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/provided-gold.diff @@ -0,0 +1,53 @@ +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index fa78105ac436f3a6d8250b773a26f1f7b789730f..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,13 +163,14 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( + relative, absolute, require_tld + ) + + return self._memoized[key] +- key = (relative, absolute, require_tld) ++ + _regex = RegexMemoizer() + + default_message = "Not a valid URL." +@@ -596,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -646,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1f102f6f0368fd0e094abd56a1a63e1b56dd6c6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/solution/solve.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index fa78105ac436f3a6d8250b773a26f1f7b789730f..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,13 +163,14 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( + relative, absolute, require_tld + ) + + return self._memoized[key] +- key = (relative, absolute, require_tld) ++ + _regex = RegexMemoizer() + + default_message = "Not a valid URL." +@@ -596,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -646,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..79a10aac58c419c71347bdc3c5c21e51a29ebc7f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:153a6a5277fb40bd0c2a12b9a815fd75b3b154dfc59e6dab4d994ee709b2a4eb" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..aeb0a32464cda14ab79b5aeade6e95a0d081cae7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d5da8d1065058166995edf6685e103e833630a6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/first-hunk-only.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index fa78105ac436f3a6d8250b773a26f1f7b789730f..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,13 +163,14 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( + relative, absolute, require_tld + ) + + return self._memoized[key] +- key = (relative, absolute, require_tld) ++ + _regex = RegexMemoizer() + + default_message = "Not a valid URL." +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__2pef8zto/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..eb61e39ac5ed4d81a4c328ca9fc488b87b839bbc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "ab59185b4dee823e0fd862b1cff46b2d85099a7fd1de514ea19d8820ea4cc5c2", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "4d0a11d46e4058a7eedcbb9d590ebceb10881cd2e660e4df1bba1cba432b4599", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "034df595ef6fe9bad772bd70964eb937296d271b4c88e8012c0fdd6ad0c92485", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "42e5da6bec8cbc05ac75aa165d6c7a5717568fa5", + "source_completion_sha256": "a1cccb807f7f51284804552e62ffa763696e194a19cd8bc84f19e094e1c2db45", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "206a6c5fc4d02b5db070a79a49101208642bb82c89312cf21df473b4d5ee8526", + "is_fork": true, + "learner_path": "tasks/1accb41ec937c71a7cae32c6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/42e5da6bec8cbc05ac75aa165d6c7a5717568fa5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "676e2850b965ed86b864af26c81c4f6046be4fe55e1cbc6b3c22df2a6a7491c5", + "provenance_path": "tasks/1accb41ec937c71a7cae32c6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "42e5da6bec8cbc05ac75aa165d6c7a5717568fa5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "b0fd137ee08832cb2fa00f7ac7ec2705e60a0705", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "task_sha256": "5ee79baa55725a76196a0d3354cf58c081412c55cf7e7a2bfc39e84aff4ee8ff", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..e8c3d4570ed4ce34c9adeab334a603e342a42187 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/instruction.md @@ -0,0 +1,45 @@ +Tuple field deserialization broken - returns list instead of tuple and inverts validation logic + +#### Description + +The Tuple field deserialization is completely broken. When deserializing valid tuple data, it raises ValidationError instead of returning the expected tuple. Additionally, it returns a list instead of a tuple when it should succeed. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields +import datetime + +# Basic tuple field test +class TestSchema(Schema): + coords = fields.Tuple([fields.Integer(), fields.Integer()]) + +schema = TestSchema() + +# This should work but raises ValidationError +try: + result = schema.load({'coords': [1, 2]}) + print("Result:", result) +except Exception as e: + print("Error:", e) + +# DateTime tuple test +class DateTimeSchema(Schema): + dt_tuple = fields.Tuple([fields.DateTime(), fields.Integer()]) + +dt_schema = DateTimeSchema() + +# This should return a tuple but fails +try: + result = dt_schema.load({'dt_tuple': ['2013-11-10T01:23:45', 42]}) + print("DateTime result:", result) + print("Type:", type(result['dt_tuple'])) # Should be tuple, not list +except Exception as e: + print("DateTime error:", e) +``` + +The tuple field seems to have inverted validation logic - it raises errors when the input is valid and tries to process invalid inputs. Also, when it does work, it returns a list instead of the expected tuple. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..7f50780f157c4433226a872fc1ee74f883f21676 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "b0fd137ee08832cb2fa00f7ac7ec2705e60a0705", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "42e5da6bec8cbc05ac75aa165d6c7a5717568fa5" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_fields.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/fields.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2314797, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "206a6c5fc4d02b5db070a79a49101208642bb82c89312cf21df473b4d5ee8526", + "is_fork": true, + "learner_path": "tasks/1accb41ec937c71a7cae32c6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/42e5da6bec8cbc05ac75aa165d6c7a5717568fa5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "676e2850b965ed86b864af26c81c4f6046be4fe55e1cbc6b3c22df2a6a7491c5", + "provenance_path": "tasks/1accb41ec937c71a7cae32c6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "42e5da6bec8cbc05ac75aa165d6c7a5717568fa5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "b0fd137ee08832cb2fa00f7ac7ec2705e60a0705", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "task_sha256": "5ee79baa55725a76196a0d3354cf58c081412c55cf7e7a2bfc39e84aff4ee8ff", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..610039d4f415cd347932103c74949b411779cbca --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "ab59185b4dee823e0fd862b1cff46b2d85099a7fd1de514ea19d8820ea4cc5c2", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/42e5da6bec8cbc05ac75aa165d6c7a5717568fa5/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "a1cccb807f7f51284804552e62ffa763696e194a19cd8bc84f19e094e1c2db45", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "d1e0d78d765ab6a695a142a011e7e2f593eea48f9a17fb967aabc874d0708286", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "206a6c5fc4d02b5db070a79a49101208642bb82c89312cf21df473b4d5ee8526", + "is_fork": true, + "learner_path": "tasks/1accb41ec937c71a7cae32c6/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/42e5da6bec8cbc05ac75aa165d6c7a5717568fa5/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "676e2850b965ed86b864af26c81c4f6046be4fe55e1cbc6b3c22df2a6a7491c5", + "provenance_path": "tasks/1accb41ec937c71a7cae32c6/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "42e5da6bec8cbc05ac75aa165d6c7a5717568fa5", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "b0fd137ee08832cb2fa00f7ac7ec2705e60a0705", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu", + "task_sha256": "5ee79baa55725a76196a0d3354cf58c081412c55cf7e7a2bfc39e84aff4ee8ff", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..544e8546dcf378d0a09f08313e267f8f8eaf8f93 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/provided-gold.diff @@ -0,0 +1,76 @@ +diff --git a/src/marshmallow/fields.py b/src/marshmallow/fields.py +index a05ccf5e41584745286573cac77dab0f1f4b7141..e83ba198e90ba2581e16c8babcf26f3e8a8f41f0 100644 +--- a/src/marshmallow/fields.py ++++ b/src/marshmallow/fields.py +@@ -862,22 +862,25 @@ + ) + + def _deserialize(self, value, attr, data, **kwargs) -> tuple: +- if utils.is_collection(value): ++ if not utils.is_collection(value): + raise self.make_error("invalid") ++ ++ self.validate_length(value) + + result = [] + errors = {} + + for idx, (field, each) in enumerate(zip(self.tuple_fields, value)): + try: +- result.append(field.deserialize(each)) ++ result.append(field.deserialize(each, **kwargs)) + except ValidationError as error: +- result.append(None) # Always append None regardless of valid_data ++ if error.valid_data is not None: ++ result.append(error.valid_data) + errors.update({idx: error.messages}) +- if not errors: # Reverse the logic of handling errors ++ if errors: + raise ValidationError(errors, valid_data=result) + +- return result # Return a list instead of a tuple ++ return tuple(result) + + + class String(Field): +@@ -1321,15 +1324,15 @@ + self, + format: str | None = None, + *, +- timezone: dt.timezone | None = dt.timezone.utc, ++ timezone: dt.timezone | None = None, + **kwargs, + ) -> None: + super().__init__(format=format, **kwargs) +- self.timezone = None if format else timezone ++ self.timezone = timezone + + def _deserialize(self, value, attr, data, **kwargs) -> dt.datetime: + ret = super()._deserialize(value, attr, data, **kwargs) +- if not is_aware(ret): ++ if is_aware(ret): + if self.timezone is None: + raise self.make_error( + "invalid_awareness", +@@ -1337,7 +1340,7 @@ + obj_type=self.OBJ_TYPE, + ) + ret = ret.astimezone(self.timezone).replace(tzinfo=None) +- return ret.replace(hour=0) ++ return ret + + + class AwareDateTime(DateTime): +@@ -1988,9 +1991,9 @@ + return missing_ + + def _deserialize(self, value, attr, data, **kwargs): +- if self._deserialize_method is not None and callable(self._deserialize_method): +- return value +- return self._deserialize_method(value) ++ if self._deserialize_method is not None: ++ return self._deserialize_method(value) ++ return value + + + class Function(Field): diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cea5ebffec18e3835f0905d05a48ce3a745d780f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/solution/solve.sh @@ -0,0 +1,82 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/fields.py b/src/marshmallow/fields.py +index a05ccf5e41584745286573cac77dab0f1f4b7141..e83ba198e90ba2581e16c8babcf26f3e8a8f41f0 100644 +--- a/src/marshmallow/fields.py ++++ b/src/marshmallow/fields.py +@@ -862,22 +862,25 @@ + ) + + def _deserialize(self, value, attr, data, **kwargs) -> tuple: +- if utils.is_collection(value): ++ if not utils.is_collection(value): + raise self.make_error("invalid") ++ ++ self.validate_length(value) + + result = [] + errors = {} + + for idx, (field, each) in enumerate(zip(self.tuple_fields, value)): + try: +- result.append(field.deserialize(each)) ++ result.append(field.deserialize(each, **kwargs)) + except ValidationError as error: +- result.append(None) # Always append None regardless of valid_data ++ if error.valid_data is not None: ++ result.append(error.valid_data) + errors.update({idx: error.messages}) +- if not errors: # Reverse the logic of handling errors ++ if errors: + raise ValidationError(errors, valid_data=result) + +- return result # Return a list instead of a tuple ++ return tuple(result) + + + class String(Field): +@@ -1321,15 +1324,15 @@ + self, + format: str | None = None, + *, +- timezone: dt.timezone | None = dt.timezone.utc, ++ timezone: dt.timezone | None = None, + **kwargs, + ) -> None: + super().__init__(format=format, **kwargs) +- self.timezone = None if format else timezone ++ self.timezone = timezone + + def _deserialize(self, value, attr, data, **kwargs) -> dt.datetime: + ret = super()._deserialize(value, attr, data, **kwargs) +- if not is_aware(ret): ++ if is_aware(ret): + if self.timezone is None: + raise self.make_error( + "invalid_awareness", +@@ -1337,7 +1340,7 @@ + obj_type=self.OBJ_TYPE, + ) + ret = ret.astimezone(self.timezone).replace(tzinfo=None) +- return ret.replace(hour=0) ++ return ret + + + class AwareDateTime(DateTime): +@@ -1988,9 +1991,9 @@ + return missing_ + + def _deserialize(self, value, attr, data, **kwargs): +- if self._deserialize_method is not None and callable(self._deserialize_method): +- return value +- return self._deserialize_method(value) ++ if self._deserialize_method is not None: ++ return self._deserialize_method(value) ++ return value + + + class Function(Field): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..0bf91bd2321650f5f5de2196870b75070276765c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:c1a213d7a2e6ac44b8e9dd002446eed91b0dc4e0574320daedda5e68f3adcd46" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..61e038cf138aedfa4201ca1f20563fdaef6a49f7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..53557160d26606a301b0904fe502f53cf3703ef5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/first-hunk-only.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/fields.py b/src/marshmallow/fields.py +index a05ccf5e41584745286573cac77dab0f1f4b7141..e83ba198e90ba2581e16c8babcf26f3e8a8f41f0 100644 +--- a/src/marshmallow/fields.py ++++ b/src/marshmallow/fields.py +@@ -862,22 +862,25 @@ + ) + + def _deserialize(self, value, attr, data, **kwargs) -> tuple: +- if utils.is_collection(value): ++ if not utils.is_collection(value): + raise self.make_error("invalid") ++ ++ self.validate_length(value) + + result = [] + errors = {} + + for idx, (field, each) in enumerate(zip(self.tuple_fields, value)): + try: +- result.append(field.deserialize(each)) ++ result.append(field.deserialize(each, **kwargs)) + except ValidationError as error: +- result.append(None) # Always append None regardless of valid_data ++ if error.valid_data is not None: ++ result.append(error.valid_data) + errors.update({idx: error.messages}) +- if not errors: # Reverse the logic of handling errors ++ if errors: + raise ValidationError(errors, valid_data=result) + +- return result # Return a list instead of a tuple ++ return tuple(result) + + + class String(Field): +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__3v78pmpu/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..fca68c6d4c61d2bec8736c46f356c0b117a9d848 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "1048fd093420518b498f8e9d4311f4f36086433cd68e75d74525773e629edc73", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "773215a3f69b3d6b48946adc4079d92d4c9eed1f1e6ed56ddd8542cb2585d76f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "3149c3f0381357930ecff11bc91ff0196a227d5e002c622cf0cbd258e942b04d", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "74b2f27732a18272b65e0faf7054a96bec623031", + "source_completion_sha256": "6dee3d2dead7cd50e20fd5b6d32e064d6a867fcf6706178f85ba9906f0f9035e", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "e27daca16b0f70d16dc2c1cc6caadfb50831b11b7b7649c65c863cf8c3b57149", + "is_fork": true, + "learner_path": "tasks/53c8bd018d9bf08c01bed818/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/74b2f27732a18272b65e0faf7054a96bec623031/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4998bbf83ad718e24428fecf6900a2bf73ab68111eb717229898e33237cf05e5", + "provenance_path": "tasks/53c8bd018d9bf08c01bed818/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "74b2f27732a18272b65e0faf7054a96bec623031", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "753db05242377aa68a8554284225c4bdac41411d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "task_sha256": "9f2d8ff8d0bc13566c37bd6dd164b8fa34798a02263fe40c965700ebab4ee4fe", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6a71424f761270ab35e370b93457b04961517fa6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/instruction.md @@ -0,0 +1,44 @@ +OneOf validator returns None instead of value and ContainsOnly validator returns truncated sequences + +#### Description + +The OneOf validator is returning None instead of the validated value, and the ContainsOnly validator is returning truncated sequences (missing the last element). + +#### Steps/Code to Reproduce + +```python +from marshmallow import validate + +# OneOf validator issue +validator = validate.OneOf([1, 2, 3]) +result = validator(2) +print(f"Expected: 2, Got: {result}") + +# ContainsOnly validator issue +validator = validate.ContainsOnly([1, 2, 3]) +result = validator([1, 2]) +print(f"Expected: [1, 2], Got: {result}") + +result = validator("ab") # with string +print(f"Expected: 'ab', Got: '{result}'") +``` + +Expected output: +``` +Expected: 2, Got: 2 +Expected: [1, 2], Got: [1, 2] +Expected: 'ab', Got: 'ab' +``` + +Actual output: +``` +Expected: 2, Got: None +Expected: [1, 2], Got: [1] +Expected: 'ab', Got: 'a' +``` + +The OneOf validator should return the original value when validation passes, but it's returning None. The ContainsOnly validator should return the complete sequence but it's dropping the last element. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..aa52ef4655ddb777d283c0b200448366f400a8c1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "753db05242377aa68a8554284225c4bdac41411d", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "74b2f27732a18272b65e0faf7054a96bec623031" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_validate.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/validate.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2306362, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "e27daca16b0f70d16dc2c1cc6caadfb50831b11b7b7649c65c863cf8c3b57149", + "is_fork": true, + "learner_path": "tasks/53c8bd018d9bf08c01bed818/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/74b2f27732a18272b65e0faf7054a96bec623031/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4998bbf83ad718e24428fecf6900a2bf73ab68111eb717229898e33237cf05e5", + "provenance_path": "tasks/53c8bd018d9bf08c01bed818/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "74b2f27732a18272b65e0faf7054a96bec623031", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "753db05242377aa68a8554284225c4bdac41411d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "task_sha256": "9f2d8ff8d0bc13566c37bd6dd164b8fa34798a02263fe40c965700ebab4ee4fe", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..a65771c1c7907b6beb963f37b48521f26a9b834b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "1048fd093420518b498f8e9d4311f4f36086433cd68e75d74525773e629edc73", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/74b2f27732a18272b65e0faf7054a96bec623031/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "6dee3d2dead7cd50e20fd5b6d32e064d6a867fcf6706178f85ba9906f0f9035e", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "9a700f7d4617ed559fc43d55a9332473bb9591cc3b3fd9830eee94f83d529e65", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "e27daca16b0f70d16dc2c1cc6caadfb50831b11b7b7649c65c863cf8c3b57149", + "is_fork": true, + "learner_path": "tasks/53c8bd018d9bf08c01bed818/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/74b2f27732a18272b65e0faf7054a96bec623031/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "4998bbf83ad718e24428fecf6900a2bf73ab68111eb717229898e33237cf05e5", + "provenance_path": "tasks/53c8bd018d9bf08c01bed818/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "74b2f27732a18272b65e0faf7054a96bec623031", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "753db05242377aa68a8554284225c4bdac41411d", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp", + "task_sha256": "9f2d8ff8d0bc13566c37bd6dd164b8fa34798a02263fe40c965700ebab4ee4fe", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..7a6ce8f139785c3bb5bc80eeb59235342c135091 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/provided-gold.diff @@ -0,0 +1,37 @@ +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 064366fc76914b9d51e6ab7a6b559d7701bc8fb9..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -597,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -647,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb132fc5b2c7b9b06de165571069584be43e56c1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/solution/solve.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 064366fc76914b9d51e6ab7a6b559d7701bc8fb9..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -597,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -647,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3008add35092b61e45a1ccd8f27efa9f2a53b408 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:aedc3031ffe38d367e8a96cdeabe7bab4f90ecc1cb127b80ce4e9954d77e2d3e" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..9032cf32b9867e691bdbf2f10d1957a221708606 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fa077d0c28bca198755b95619a466beb86e7efb --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/first-hunk-only.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 064366fc76914b9d51e6ab7a6b559d7701bc8fb9..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -597,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__5m9xnodp/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..c463fb880539c38bf3269fd1f9256ee28f715f77 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "b67b0ad4e8ca96e44112a28362fe166992752cc63445de199b547a095b4ee262", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "06eb094e6f12221cd1426b9333d230d88892436ebd2e2aa822df72cbfe60d996", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "7cd78d4bba8a5b5b414d130573b90919246178130c0bea0dec363166a8639bae", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "bd2595eced181a6d9779f11ac830d1954dfbcec9", + "source_completion_sha256": "5eb95ab0a095fe41843a58011d22d51487bc05dc4699c3f7875a6c9b9869f503", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "ef60c34cc5d00e765d87b990f1b5c8e7ed0bbe66575f0cd1eac5eb4abe4faedc", + "is_fork": true, + "learner_path": "tasks/97cd5e533247986d60bd209e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/bd2595eced181a6d9779f11ac830d1954dfbcec9/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "82bc947120a10bbafe57e8325c70585d1a3bc420713f7cb355daec15c4a4de24", + "provenance_path": "tasks/97cd5e533247986d60bd209e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "bd2595eced181a6d9779f11ac830d1954dfbcec9", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d317ff6475d58e405bad9f3d77a801caa0f63ee7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "task_sha256": "dfef7f7e8e09b7d1fb437c004001b0ab4c9edcb5577514d6af50a5e8e20293fd", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..eed0f85f4638b5a8e5b7ca644d6c9c39cd1aa9c4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/instruction.md @@ -0,0 +1,42 @@ +DateTime serialization truncates seconds and microseconds + +#### Description + +When serializing datetime objects, the output is unexpectedly truncated to only show hours and minutes, omitting seconds and microseconds entirely. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields +import datetime as dt + +class TestSchema(Schema): + timestamp = fields.DateTime() + +# Test with seconds +data = {'timestamp': dt.datetime(2013, 11, 10, 1, 23, 45)} +result = TestSchema().dump(data) +print(f"Expected: 2013-11-10T01:23:45") +print(f"Actual: {result['timestamp']}") + +# Test with microseconds +data_micro = {'timestamp': dt.datetime(2013, 11, 10, 1, 23, 45, 123456)} +result_micro = TestSchema().dump(data_micro) +print(f"Expected: 2013-11-10T01:23:45.123456") +print(f"Actual: {result_micro['timestamp']}") +``` + +The output shows: +``` +Expected: 2013-11-10T01:23:45 +Actual: 2013-11-10T01:23 + +Expected: 2013-11-10T01:23:45.123456 +Actual: 2013-11-10T01:23 +``` + +This affects all datetime serialization including when using explicit ISO formats and timezone-aware datetimes. The issue also breaks time parsing functionality completely. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..010a3c1df062b1c5233794610ccabc376d46c7f3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "d317ff6475d58e405bad9f3d77a801caa0f63ee7", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "bd2595eced181a6d9779f11ac830d1954dfbcec9" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_error_store.py", + "tests/test_serialization.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/utils.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2287300, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "ef60c34cc5d00e765d87b990f1b5c8e7ed0bbe66575f0cd1eac5eb4abe4faedc", + "is_fork": true, + "learner_path": "tasks/97cd5e533247986d60bd209e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/bd2595eced181a6d9779f11ac830d1954dfbcec9/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "82bc947120a10bbafe57e8325c70585d1a3bc420713f7cb355daec15c4a4de24", + "provenance_path": "tasks/97cd5e533247986d60bd209e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "bd2595eced181a6d9779f11ac830d1954dfbcec9", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d317ff6475d58e405bad9f3d77a801caa0f63ee7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "task_sha256": "dfef7f7e8e09b7d1fb437c004001b0ab4c9edcb5577514d6af50a5e8e20293fd", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b131ee269032e7b97b81919629d8caf24f9a1e8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "b67b0ad4e8ca96e44112a28362fe166992752cc63445de199b547a095b4ee262", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/bd2595eced181a6d9779f11ac830d1954dfbcec9/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "5eb95ab0a095fe41843a58011d22d51487bc05dc4699c3f7875a6c9b9869f503", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "929da112e48fcbdc3f6bf8d755243098bbff12dd582c6671efc8b7faf1f672f9", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "ef60c34cc5d00e765d87b990f1b5c8e7ed0bbe66575f0cd1eac5eb4abe4faedc", + "is_fork": true, + "learner_path": "tasks/97cd5e533247986d60bd209e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/bd2595eced181a6d9779f11ac830d1954dfbcec9/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "82bc947120a10bbafe57e8325c70585d1a3bc420713f7cb355daec15c4a4de24", + "provenance_path": "tasks/97cd5e533247986d60bd209e/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "bd2595eced181a6d9779f11ac830d1954dfbcec9", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d317ff6475d58e405bad9f3d77a801caa0f63ee7", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3", + "task_sha256": "dfef7f7e8e09b7d1fb437c004001b0ab4c9edcb5577514d6af50a5e8e20293fd", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..4efac3481c7434a1e08c2c8aa264975bfc296fdd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/provided-gold.diff @@ -0,0 +1,47 @@ +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index ac449ee76428f5ec6bfbe8f01e9e59b285751f42..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -169,17 +169,18 @@ + + + def from_iso_time(value): ++ """Parse a string and return a datetime.time. ++ ++ This function doesn't support time zone offsets. ++ """ + match = _iso8601_time_re.match(value) +- return dt.time(**kw) + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") ++ kw = match.groupdict() + kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") +- """Parse a string and return a datetime.time. +- +- This function doesn't support time zone offsets. +- """ + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw = match.groupdict() ++ return dt.time(**kw) ++ + + def from_iso_date(value): + """Parse a string and return a datetime.date.""" +@@ -230,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9fbc167463dab82631e742a2bb13171c6f8a606 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/solution/solve.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index ac449ee76428f5ec6bfbe8f01e9e59b285751f42..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -169,17 +169,18 @@ + + + def from_iso_time(value): ++ """Parse a string and return a datetime.time. ++ ++ This function doesn't support time zone offsets. ++ """ + match = _iso8601_time_re.match(value) +- return dt.time(**kw) + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") ++ kw = match.groupdict() + kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") +- """Parse a string and return a datetime.time. +- +- This function doesn't support time zone offsets. +- """ + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw = match.groupdict() ++ return dt.time(**kw) ++ + + def from_iso_date(value): + """Parse a string and return a datetime.date.""" +@@ -230,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..28ede7bd75e844842f4d7ac64208d48c206e0971 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:6ae07aabe88dc5c96ab9914405148e296cdc7ae66f2f442f615c62e0aab36f07" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..3c221ad242d429cb00d76d88eb06871da72c1a46 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..9477fe9ba78b8019e325f14fd18e5de7a745aa24 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index ac449ee76428f5ec6bfbe8f01e9e59b285751f42..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ajnurbb3/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..727110dde8702b4fa1c7959c669fa55023d57ced --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "a0a52c7e4abc22af51f519cc6a8a8fecfeb4ffca907f0fa76799c5b13a094cb5", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "84f8382c03b3fa639f05562eae10a20335decc6571e445f0067cd5982f32837f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "7643b42901baa122c547d926df04b249bbfc01a26d9c3f5997141df461392f33", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "406cfdb32e229314e4cb2562555e3b273530b5a6", + "source_completion_sha256": "22709d6106f755072c6aa6c05c9d899d963024fff6d4017dc3418b61570ae94c", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "49d08adfaa4a1e51566e3a0988181ef029d0efbe110456f7e19a310b9341b6e4", + "is_fork": true, + "learner_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/406cfdb32e229314e4cb2562555e3b273530b5a6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "d75e7136686d37bb0d93f92c3c7b5d45349f3a11aded52dcecba08b1e769a01a", + "provenance_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "406cfdb32e229314e4cb2562555e3b273530b5a6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "590a701e251b3ec6872426de11ce1a1127ae280b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "task_sha256": "0ecee68add7fb4e79b1a84322ae00e40d6edef9f9819a996b54183510d4e6a0a", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..4e62312d2fedc9e15f7f96166d4dc75f29dc45fb --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/instruction.md @@ -0,0 +1,25 @@ +OrderedSet repr shows empty brackets instead of items when populated + +#### Description + +The `__repr__` method of `OrderedSet` is displaying incorrect output. When the set contains items, it shows empty brackets `[]` instead of the actual contents, and when empty, it shows the contents instead of empty parentheses. + +#### Steps/Code to Reproduce + +```python +from marshmallow.orderedset import OrderedSet + +# Create an empty OrderedSet +empty_set = OrderedSet() +print(repr(empty_set)) # Expected: OrderedSet(), Actual: OrderedSet(['item1', 'item2']) + +# Create a populated OrderedSet +populated_set = OrderedSet(['item1', 'item2']) +print(repr(populated_set)) # Expected: OrderedSet(['item1', 'item2']), Actual: OrderedSet[] +``` + +The repr output is backwards - empty sets show content and populated sets show empty brackets. This makes debugging and logging confusing since the string representation doesn't match the actual state of the object. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..d03bc1270733f16b753da3515317d8f8b588ef1d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "590a701e251b3ec6872426de11ce1a1127ae280b", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "406cfdb32e229314e4cb2562555e3b273530b5a6" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_decorators.py", + "tests/test_deserialization.py", + "tests/test_fields.py", + "tests/test_options.py", + "tests/test_schema.py", + "tests/test_serialization.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/orderedset.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2143920, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "49d08adfaa4a1e51566e3a0988181ef029d0efbe110456f7e19a310b9341b6e4", + "is_fork": true, + "learner_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/406cfdb32e229314e4cb2562555e3b273530b5a6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "d75e7136686d37bb0d93f92c3c7b5d45349f3a11aded52dcecba08b1e769a01a", + "provenance_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "406cfdb32e229314e4cb2562555e3b273530b5a6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "590a701e251b3ec6872426de11ce1a1127ae280b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "task_sha256": "0ecee68add7fb4e79b1a84322ae00e40d6edef9f9819a996b54183510d4e6a0a", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..23f28211ee6fe540f94958a025af7ffb56a8ade1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "a0a52c7e4abc22af51f519cc6a8a8fecfeb4ffca907f0fa76799c5b13a094cb5", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/406cfdb32e229314e4cb2562555e3b273530b5a6/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "22709d6106f755072c6aa6c05c9d899d963024fff6d4017dc3418b61570ae94c", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "4c671629ea6ceb42c355ce45b9331af10ce03ef2b07fde33a828e1a3e26c1d2e", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "49d08adfaa4a1e51566e3a0988181ef029d0efbe110456f7e19a310b9341b6e4", + "is_fork": true, + "learner_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/406cfdb32e229314e4cb2562555e3b273530b5a6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "d75e7136686d37bb0d93f92c3c7b5d45349f3a11aded52dcecba08b1e769a01a", + "provenance_path": "tasks/0dc0d4d1cae85bcad8ab8ae5/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "406cfdb32e229314e4cb2562555e3b273530b5a6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "590a701e251b3ec6872426de11ce1a1127ae280b", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz", + "task_sha256": "0ecee68add7fb4e79b1a84322ae00e40d6edef9f9819a996b54183510d4e6a0a", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..dda7a8e1038cd9c0288cb0a15c980473faea0d3f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/provided-gold.diff @@ -0,0 +1,28 @@ +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 7c0d40f8d1356c95706ee9219723275a05d29ba5..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -40,8 +40,8 @@ + def add(self, key): + if key not in self.map: + end = self.end +- curr = end[2] +- end[1] = curr[2] = self.map[key] = [key, curr, end] ++ curr = end[1] ++ curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): + if key in self.map: +@@ -71,9 +71,9 @@ + return key + + def __repr__(self): +- if self: +- return f"{self.__class__.__name__}[]" +- return f"{self.__class__.__name__}({list(self)})" ++ if not self: ++ return f"{self.__class__.__name__}()" ++ return f"{self.__class__.__name__}({list(self)!r})" + + def __eq__(self, other): + if isinstance(other, OrderedSet): diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5fe87c428ce54531778ee69c313e5fe91caf1ea5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/solution/solve.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 7c0d40f8d1356c95706ee9219723275a05d29ba5..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -40,8 +40,8 @@ + def add(self, key): + if key not in self.map: + end = self.end +- curr = end[2] +- end[1] = curr[2] = self.map[key] = [key, curr, end] ++ curr = end[1] ++ curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): + if key in self.map: +@@ -71,9 +71,9 @@ + return key + + def __repr__(self): +- if self: +- return f"{self.__class__.__name__}[]" +- return f"{self.__class__.__name__}({list(self)})" ++ if not self: ++ return f"{self.__class__.__name__}()" ++ return f"{self.__class__.__name__}({list(self)!r})" + + def __eq__(self, other): + if isinstance(other, OrderedSet): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..48dcba81949a431163a5de8a2cfde0e02044b3ec --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:3e12abfb623439e7cc424f71137afc905d72a06556098a6598bf498c6c5be542" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..0494ce2c1130ad233dd17cbc64f251c3a6e1271c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..25e8cf03f09f27d40750f7db15f2c8c08c4020b5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/first-hunk-only.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 7c0d40f8d1356c95706ee9219723275a05d29ba5..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -40,8 +40,8 @@ + def add(self, key): + if key not in self.map: + end = self.end +- curr = end[2] +- end[1] = curr[2] = self.map[key] = [key, curr, end] ++ curr = end[1] ++ curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): + if key in self.map: +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__e633n9uz/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..8611e825abd125297f008bf8421b8244c0fea8ed --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "745b1d2201d3eb2b1ab309878cdfda9231df371ab996a9d89f1d1739d9af0a75", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "66494964928cf911476a1c2621c7ea28ec098ee00bc7c36580aac1695307d797", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "4762d77166c7135df0520a0aee372f1e60fcbd68bdd77109cbc4a16247118c82", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "e5fb677f18c5098a544a8813199ef7820fc49bc6", + "source_completion_sha256": "c13fa0bbd8486b5b775474555ab2a81254b1fc094e17d2597bb82c154cd9c488", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "65f5374c8367ff3f89fbaea401c3ba8a3c1ae5df967a6703ff41dbaedee84edd", + "is_fork": true, + "learner_path": "tasks/affde655ce44b1d37f2fe7be/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e5fb677f18c5098a544a8813199ef7820fc49bc6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "40c6d8cb9a357b7de8308c6503636b985626992846c381dd9f9be50eab887218", + "provenance_path": "tasks/affde655ce44b1d37f2fe7be/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e5fb677f18c5098a544a8813199ef7820fc49bc6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "bd790bc27cb55457b843e74dfe62644605c629b8", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "task_sha256": "52683adc41109d9df47ed33e722cd3bba4f6dbb12355dbd86b8c6c6fe180cd07", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..6742b3b8a1384bfdc9f012b14e21fe101f9d7df4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/instruction.md @@ -0,0 +1,34 @@ +ISO time parsing adds extra second and missing object evaluates to True + +#### Description + +When parsing ISO time strings, the time parser is incorrectly adding an extra second to the result and the missing object now evaluates to True instead of False, breaking conditional logic that depends on missing values being falsy. + +#### Steps/Code to Reproduce + +```python +from marshmallow.utils import from_iso_time +from marshmallow import missing +import datetime + +# ISO time parsing issue +result = from_iso_time('01:23:45.123') +print(f"Parsed: {result}") +print(f"Expected: {datetime.time(1, 23, 45, 123000)}") + +# Missing object boolean evaluation issue +print(f"missing evaluates to: {bool(missing)}") +print(f"Expected: False") + +# This breaks conditional logic +if missing: + print("This should not print!") +else: + print("This should print but won't now") +``` + +The time parsing is adding an extra second (01:23:46 instead of 01:23:45) and the missing object now returns True when used in boolean context, which breaks existing code that relies on missing being falsy. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..347ff46fedd236da952608192372df40f02d6047 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "bd790bc27cb55457b843e74dfe62644605c629b8", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "e5fb677f18c5098a544a8813199ef7820fc49bc6" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_error_store.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/utils.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2326426, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "65f5374c8367ff3f89fbaea401c3ba8a3c1ae5df967a6703ff41dbaedee84edd", + "is_fork": true, + "learner_path": "tasks/affde655ce44b1d37f2fe7be/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e5fb677f18c5098a544a8813199ef7820fc49bc6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "40c6d8cb9a357b7de8308c6503636b985626992846c381dd9f9be50eab887218", + "provenance_path": "tasks/affde655ce44b1d37f2fe7be/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e5fb677f18c5098a544a8813199ef7820fc49bc6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "bd790bc27cb55457b843e74dfe62644605c629b8", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "task_sha256": "52683adc41109d9df47ed33e722cd3bba4f6dbb12355dbd86b8c6c6fe180cd07", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..eddd12dac6f9b3a038b78537a8b433ad5957fce0 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "745b1d2201d3eb2b1ab309878cdfda9231df371ab996a9d89f1d1739d9af0a75", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e5fb677f18c5098a544a8813199ef7820fc49bc6/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "c13fa0bbd8486b5b775474555ab2a81254b1fc094e17d2597bb82c154cd9c488", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "97f517d4f67d8caa6fd620e670ad104d0c6f9fef91f4ab3d4219772d0004d27b", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "65f5374c8367ff3f89fbaea401c3ba8a3c1ae5df967a6703ff41dbaedee84edd", + "is_fork": true, + "learner_path": "tasks/affde655ce44b1d37f2fe7be/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e5fb677f18c5098a544a8813199ef7820fc49bc6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "40c6d8cb9a357b7de8308c6503636b985626992846c381dd9f9be50eab887218", + "provenance_path": "tasks/affde655ce44b1d37f2fe7be/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e5fb677f18c5098a544a8813199ef7820fc49bc6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "bd790bc27cb55457b843e74dfe62644605c629b8", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6", + "task_sha256": "52683adc41109d9df47ed33e722cd3bba4f6dbb12355dbd86b8c6c6fe180cd07", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..c1732fda97bd027e5b27efd5bfaa7b5a22dc510e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/provided-gold.diff @@ -0,0 +1,24 @@ +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index 2f4548acb2f58357d9e2264727a0a6bf5830ec0f..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e775ba920b081d9376ddd9fbeadf33aa2732f3f1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/solution/solve.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index 2f4548acb2f58357d9e2264727a0a6bf5830ec0f..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..4dafcbce5fc5536bbe3c929623d2ef76de418894 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:a014208177fbfce39f2970e85fe0492c255c657e9931342ec30bab362b87f1f6" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d137108f2115aeaae7697b3b4e214ac82e3a2221 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b06c682157cf322ab6989e7c179fb4538827bae --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index 2f4548acb2f58357d9e2264727a0a6bf5830ec0f..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__f7dp1va6/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..0e757be4f7b6e3e11f0e67092f2066d6bc5cbb81 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "c4f7b37631f21d2bcd36648467733a9fff0384e955f69f854c084c8849baeab2", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "864db04b39a66eded06f6e8f0185259a0a7b3f49f72a5ccd0f5d68ed7956403b", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "0cbd4c8aa5d2a96d613aa24e63f583af1e69997de9d1547ae7dda1f0c9910e1d", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6", + "source_completion_sha256": "46fb37911429e48b7fb37797a858913d997eaaf7bb354c06ff6c2e60f9901cb5", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "47a4ffea3c5dc7f3698d300b18397c6ff4db0019f4676d7d3347a4360a826b4f", + "is_fork": true, + "learner_path": "tasks/d77b03b7d07f8050a66557e1/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "fcec8d0ef7c5c0d9466a1bd6bb18be2a0d4f305358eae83b3ec9848e5a659715", + "provenance_path": "tasks/d77b03b7d07f8050a66557e1/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "80e0c235d80f33a309f2618b45ad65fb21117d40", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "task_sha256": "65d1f81f332053e1e1a89d8526a02543ab70fd3a416eb5256d3ec0966766b22d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..51d45ef5fc229602300de200e0615b5ac76e0f66 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/instruction.md @@ -0,0 +1,32 @@ +OrderedSet equality comparison broken after discard operation + +#### Description + +When using OrderedSet and performing discard operations, the equality comparison becomes broken. The OrderedSet no longer compares equal to regular sets or other OrderedSets with the same elements. + +#### Steps/Code to Reproduce + +```python +from marshmallow.orderedset import OrderedSet + +# Create an OrderedSet and discard an element +os = OrderedSet(['a', 'b', 'c']) +os.discard('b') + +# This should be True but returns False +print(os == {'a', 'c'}) # Expected: True, Actual: False + +# Even comparing with another OrderedSet fails +os2 = OrderedSet(['a', 'c']) +print(os == os2) # Expected: True, Actual: False + +# The elements are correct when iterating +print(list(os)) # ['a', 'c'] - this is correct +print(set(os)) # {'a', 'c'} - this is also correct +``` + +The issue appears after calling `discard()` on an OrderedSet. The internal structure seems to get corrupted, causing equality comparisons to fail even when the sets contain the same elements in the same order. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..80143f1d4f29ee0bda6872879dcd3206aa658c8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_schema.py::test_nested_only_inheritance" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "80e0c235d80f33a309f2618b45ad65fb21117d40", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_deserialization.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_fields.py", + "tests/test_schema.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/orderedset.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2310129, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "47a4ffea3c5dc7f3698d300b18397c6ff4db0019f4676d7d3347a4360a826b4f", + "is_fork": true, + "learner_path": "tasks/d77b03b7d07f8050a66557e1/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "fcec8d0ef7c5c0d9466a1bd6bb18be2a0d4f305358eae83b3ec9848e5a659715", + "provenance_path": "tasks/d77b03b7d07f8050a66557e1/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "80e0c235d80f33a309f2618b45ad65fb21117d40", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "task_sha256": "65d1f81f332053e1e1a89d8526a02543ab70fd3a416eb5256d3ec0966766b22d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..2493acee0eb427ac4fce57844dc5dece6b77ea15 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "c4f7b37631f21d2bcd36648467733a9fff0384e955f69f854c084c8849baeab2", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "46fb37911429e48b7fb37797a858913d997eaaf7bb354c06ff6c2e60f9901cb5", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "80e58ea8cc152a977cbedf6ccbbee63fc4dbb2e566134d3d5c467015d838663f", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "47a4ffea3c5dc7f3698d300b18397c6ff4db0019f4676d7d3347a4360a826b4f", + "is_fork": true, + "learner_path": "tasks/d77b03b7d07f8050a66557e1/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "fcec8d0ef7c5c0d9466a1bd6bb18be2a0d4f305358eae83b3ec9848e5a659715", + "provenance_path": "tasks/d77b03b7d07f8050a66557e1/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "79118fb52f2f38eace5af5a2aa4a3c2f8ca8dea6", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "80e0c235d80f33a309f2618b45ad65fb21117d40", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj", + "task_sha256": "65d1f81f332053e1e1a89d8526a02543ab70fd3a416eb5256d3ec0966766b22d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..14db13efd663a1378bde0c8609938f9a98e40a43 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/provided-gold.diff @@ -0,0 +1,29 @@ +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 0c039d6be3999b07f48bfc153719cadd3927cc50..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +@@ -77,8 +77,8 @@ + + def __eq__(self, other): + if isinstance(other, OrderedSet): +- return len(self) == len(other) and self != other +- return set(self) != set(other) ++ return len(self) == len(other) and list(self) == list(other) ++ return set(self) == set(other) + + + if __name__ == "__main__": diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..37f770ce276c8415ae547b70c87122e29d3ddbab --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/solution/solve.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 0c039d6be3999b07f48bfc153719cadd3927cc50..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +@@ -77,8 +77,8 @@ + + def __eq__(self, other): + if isinstance(other, OrderedSet): +- return len(self) == len(other) and self != other +- return set(self) != set(other) ++ return len(self) == len(other) and list(self) == list(other) ++ return set(self) == set(other) + + + if __name__ == "__main__": +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..23476a7a356b4fa2d0b911f9eb32e9923a3210e7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:11bf48360385e0a6ad86c6d48326123ded7a7ade3a3260f0687c1bec565df5c3" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d7cd35e6ed8dab7a888e6718463ff443d6d1266c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_schema.py::test_nested_only_inheritance" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ac6f0dfcc9ad0708b3d99d7d033969cf784d0cb --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/first-hunk-only.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 0c039d6be3999b07f48bfc153719cadd3927cc50..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__hl6a0ryj/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..42f26b8de0e700dc6fa6bd1cfe88719f05eb90f8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "31bc8a31435b18f362e492b85b7205648889ef8caf874c3a5b3153898e1451e0", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "7efb7e5747037a27320d6dd3cd78ea008d006a9ae7e69c160af49c0232ca31c8", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "5123f004b14006252a6dbc0d3326644161328e678ef3bdb2b50f178710c67b84", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "8648117ad39abe76b2ece55b1cf2dc6fe252b543", + "source_completion_sha256": "32d7c90cc29aa26fedf31ed5650870628fcd363305b98754fa5ecce942caea15", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "5a83e19fb548e068de8b69e2b0d01838678bd3b4b09c7cd003657ec4c0eb9b14", + "is_fork": true, + "learner_path": "tasks/33271fe2aad8764b4c03bbe7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/8648117ad39abe76b2ece55b1cf2dc6fe252b543/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "30a90e3e7c874e24efdc945d4f195d06abdbd747ba374adca2b74234f366c006", + "provenance_path": "tasks/33271fe2aad8764b4c03bbe7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "8648117ad39abe76b2ece55b1cf2dc6fe252b543", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "f66342ad936b817f8d81acd1a3ac46ec07f21597", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "task_sha256": "cb3d3964bac89340de198a55df418026e7d79b42c594a52c9cb20948cdc8b6ce", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..56c29c0f64c01099d8e91ed586d6d8d44c3ff448 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/instruction.md @@ -0,0 +1,31 @@ +OrderedSet discard method corrupts internal structure + +#### Description + +The `OrderedSet.discard()` method appears to be corrupting the internal linked list structure, causing the set to behave incorrectly. After discarding elements, the OrderedSet shows unexpected behavior in iteration and representation. + +#### Steps/Code to Reproduce + +```python +from marshmallow.orderedset import OrderedSet + +# Create an OrderedSet with some elements +os = OrderedSet(['a', 'b', 'c']) +print(f"Original: {os}") # Should show OrderedSet(['a', 'b', 'c']) + +# Discard an element +os.discard('b') +print(f"After discard: {os}") # Shows OrderedSet[] instead of OrderedSet(['a', 'c']) + +# Check if elements are still there +print(f"Length: {len(os)}") # Shows 2, which is correct +print(f"'a' in os: {'a' in os}") # Shows True +print(f"'c' in os: {'c' in os}") # Shows True +print(f"List conversion: {list(os)}") # May show unexpected results +``` + +The issue manifests when trying to discard elements from an OrderedSet - the internal representation becomes corrupted and the `__repr__` method shows `OrderedSet[]` even when the set contains elements. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..ed7b4682b1a8f54be827090c1a94db4f0e71d31b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "f66342ad936b817f8d81acd1a3ac46ec07f21597", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "8648117ad39abe76b2ece55b1cf2dc6fe252b543" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_deserialization.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_fields.py", + "tests/test_schema.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/orderedset.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2310117, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "5a83e19fb548e068de8b69e2b0d01838678bd3b4b09c7cd003657ec4c0eb9b14", + "is_fork": true, + "learner_path": "tasks/33271fe2aad8764b4c03bbe7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/8648117ad39abe76b2ece55b1cf2dc6fe252b543/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "30a90e3e7c874e24efdc945d4f195d06abdbd747ba374adca2b74234f366c006", + "provenance_path": "tasks/33271fe2aad8764b4c03bbe7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "8648117ad39abe76b2ece55b1cf2dc6fe252b543", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "f66342ad936b817f8d81acd1a3ac46ec07f21597", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "task_sha256": "cb3d3964bac89340de198a55df418026e7d79b42c594a52c9cb20948cdc8b6ce", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..25fc47aa72bb5b2dea3619678d432eec79a3960a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "31bc8a31435b18f362e492b85b7205648889ef8caf874c3a5b3153898e1451e0", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/8648117ad39abe76b2ece55b1cf2dc6fe252b543/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "32d7c90cc29aa26fedf31ed5650870628fcd363305b98754fa5ecce942caea15", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "e8781173efe3e62187e19a82e18239e9af8cef0dcde6142c45d628b1f62f9c14", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "5a83e19fb548e068de8b69e2b0d01838678bd3b4b09c7cd003657ec4c0eb9b14", + "is_fork": true, + "learner_path": "tasks/33271fe2aad8764b4c03bbe7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/8648117ad39abe76b2ece55b1cf2dc6fe252b543/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "30a90e3e7c874e24efdc945d4f195d06abdbd747ba374adca2b74234f366c006", + "provenance_path": "tasks/33271fe2aad8764b4c03bbe7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "8648117ad39abe76b2ece55b1cf2dc6fe252b543", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "f66342ad936b817f8d81acd1a3ac46ec07f21597", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8", + "task_sha256": "cb3d3964bac89340de198a55df418026e7d79b42c594a52c9cb20948cdc8b6ce", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..fe71897698aacfdb7cdc6de56dc9616dbb0e00b5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/provided-gold.diff @@ -0,0 +1,38 @@ +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 2796ac0568eba1f007e80c188d1977254814aef1..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +@@ -71,14 +71,14 @@ + return key + + def __repr__(self): +- if self: +- return f"{self.__class__.__name__}[]" +- return f"{self.__class__.__name__}({list(self)})" ++ if not self: ++ return f"{self.__class__.__name__}()" ++ return f"{self.__class__.__name__}({list(self)!r})" + + def __eq__(self, other): + if isinstance(other, OrderedSet): +- return len(self) == len(other) and self != other +- return set(self) != set(other) ++ return len(self) == len(other) and list(self) == list(other) ++ return set(self) == set(other) + + + if __name__ == "__main__": diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ac924491fe0e061bb0729a14994905ba0b90c05 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/solution/solve.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 2796ac0568eba1f007e80c188d1977254814aef1..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +@@ -71,14 +71,14 @@ + return key + + def __repr__(self): +- if self: +- return f"{self.__class__.__name__}[]" +- return f"{self.__class__.__name__}({list(self)})" ++ if not self: ++ return f"{self.__class__.__name__}()" ++ return f"{self.__class__.__name__}({list(self)!r})" + + def __eq__(self, other): + if isinstance(other, OrderedSet): +- return len(self) == len(other) and self != other +- return set(self) != set(other) ++ return len(self) == len(other) and list(self) == list(other) ++ return set(self) == set(other) + + + if __name__ == "__main__": +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..af7db71171b2e2bd0270c8e20c665ce7de32132c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:98c87f16a54454ad0294a3c15be9f0e1d4cd8e698d83f4084803dd146b714ce4" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d7e5855951a3b14a1ef9ace8e1ecc89168493710 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..d2a31f4fec30ca2a54f6209af8abb0bf0fe5c6f9 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/first-hunk-only.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/orderedset.py b/src/marshmallow/orderedset.py +index 2796ac0568eba1f007e80c188d1977254814aef1..7ce0723ac42d747071755d9339c953f4669a0976 100644 +--- a/src/marshmallow/orderedset.py ++++ b/src/marshmallow/orderedset.py +@@ -44,10 +44,10 @@ + curr[2] = end[1] = self.map[key] = [key, curr, end] + + def discard(self, key): +- if key in self.map: ++ if key in self.map: + key, prev, next = self.map.pop(key) +- prev[1] = next # (the bug) Changed from prev[2] = next to prev[1] = next +- next[2] = prev # (the bug) Changed from next[1] = prev to next[2] = prev ++ prev[2] = next ++ next[1] = prev + + def __iter__(self): + end = self.end +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__igov6tf8/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..c42ef352e4f46628c64e30757741fd45692937c6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "b3d5e2a05e1026f78ef81c9d207d827217236e2489a4152264d200173a2f9c8b", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "b0fa416a3391c1150442a74f1639276a9664dc644a84241bdb51e88491b520d7", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "f04fc91b13b029620c0cada8a648f82aed83fee17d50c3f958c51e270d769619", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "d1b21d4666a97fff5d77c35a686bd6a3aafb4033", + "source_completion_sha256": "6ca14182215da51e50beb4b456209171a64b952a4fc8a63c4c6409d89503e153", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "92db8bb1c3578d8b315ecc8a65320c0e4a9f7160e43992c9c8776aed5f44dab3", + "is_fork": true, + "learner_path": "tasks/61a884852c167d1ffac25dd2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/d1b21d4666a97fff5d77c35a686bd6a3aafb4033/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "3ff959e143f11e13497dc0762d5512f27481f003b6abccf6808cd134ea1eba8e", + "provenance_path": "tasks/61a884852c167d1ffac25dd2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d1b21d4666a97fff5d77c35a686bd6a3aafb4033", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "71a066d35e9fc8a4556c9c217a20cf27205db226", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "task_sha256": "bcdf700e02f8255130b195c07e7b6db2c0135282029db4f7c8b495865f53b670", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..49e5bbd0b481db8c03df8c9da8ceb74f32ff4380 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/instruction.md @@ -0,0 +1,52 @@ +# pre_dump and pre_load decorators pass incorrect 'many' parameter + +## Description + +I've discovered an issue with the `pre_dump` and `pre_load` decorators in marshmallow. When using these decorators with the `pass_many` parameter, the value is being inverted, causing unexpected behavior. + +## Steps to reproduce + +Create a schema with decorated methods: + +```python +class ExampleSchema(Schema): + value = fields.Integer(as_string=True) + + @pre_dump + def increment_value(self, item, **kwargs): + # This should receive the correct 'many' parameter + item['value'] += 1 + return item + + @pre_load(pass_many=True) + def remove_envelope(self, data, many, **kwargs): + # The 'many' parameter here is incorrect + key = 'data' if many else 'datum' + return data[key] +``` + +When using this schema to serialize/deserialize data: + +```python +schema = ExampleSchema() +item = {'value': 3} +items = [{'value': 3}, {'value': 5}] + +# This fails with KeyError: 'value' +item_dumped = schema.dump(item) +items_dumped = schema.dump(items, many=True) +``` + +## Expected behavior + +The decorated methods should receive the correct value for the `many` parameter, matching the actual serialization context. When `pass_many=True` is specified, the method should receive the actual value of `many` as passed to `dump()` or `load()`. + +## Actual behavior + +The `many` parameter is being inverted for `pre_dump` and `pre_load` decorators. This causes the decorated methods to receive the wrong value, leading to errors when trying to process the data. + +For example, when serializing a single item (where `many=False`), the decorated method receives `many=True` instead, causing it to try to process the item as if it were a collection. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..981d3ab01c07166426049e9d7559a0fda81ebee5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "71a066d35e9fc8a4556c9c217a20cf27205db226", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "d1b21d4666a97fff5d77c35a686bd6a3aafb4033" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_deserialization.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_decorators.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/decorators.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2396394, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "92db8bb1c3578d8b315ecc8a65320c0e4a9f7160e43992c9c8776aed5f44dab3", + "is_fork": true, + "learner_path": "tasks/61a884852c167d1ffac25dd2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/d1b21d4666a97fff5d77c35a686bd6a3aafb4033/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "3ff959e143f11e13497dc0762d5512f27481f003b6abccf6808cd134ea1eba8e", + "provenance_path": "tasks/61a884852c167d1ffac25dd2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d1b21d4666a97fff5d77c35a686bd6a3aafb4033", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "71a066d35e9fc8a4556c9c217a20cf27205db226", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "task_sha256": "bcdf700e02f8255130b195c07e7b6db2c0135282029db4f7c8b495865f53b670", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..903398c2270ea9a6700fd2dae4d5515690ceea2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "b3d5e2a05e1026f78ef81c9d207d827217236e2489a4152264d200173a2f9c8b", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/d1b21d4666a97fff5d77c35a686bd6a3aafb4033/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "6ca14182215da51e50beb4b456209171a64b952a4fc8a63c4c6409d89503e153", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "128dd440befdba9c06a6504c0b384d927c0d11e0a345b3d63f76e60cfee2f749", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "92db8bb1c3578d8b315ecc8a65320c0e4a9f7160e43992c9c8776aed5f44dab3", + "is_fork": true, + "learner_path": "tasks/61a884852c167d1ffac25dd2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/d1b21d4666a97fff5d77c35a686bd6a3aafb4033/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "3ff959e143f11e13497dc0762d5512f27481f003b6abccf6808cd134ea1eba8e", + "provenance_path": "tasks/61a884852c167d1ffac25dd2/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d1b21d4666a97fff5d77c35a686bd6a3aafb4033", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "71a066d35e9fc8a4556c9c217a20cf27205db226", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96", + "task_sha256": "bcdf700e02f8255130b195c07e7b6db2c0135282029db4f7c8b495865f53b670", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..f5b1d1ac94972aae9d1d0a343b8d159bb0e7aba5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/provided-gold.diff @@ -0,0 +1,22 @@ +diff --git a/src/marshmallow/decorators.py b/src/marshmallow/decorators.py +index a28d791a2b025919f6a61e6a9b7171d5b904052d..965edb68b7ddd2eeaba41aa49e51d2dd7c2440db 100644 +--- a/src/marshmallow/decorators.py ++++ b/src/marshmallow/decorators.py +@@ -138,7 +138,7 @@ + .. versionchanged:: 3.0.0 + ``many`` is always passed as a keyword arguments to the decorated method. + """ +- return set_hook(fn, PRE_DUMP, many=not pass_many) ++ return set_hook(fn, PRE_DUMP, many=pass_many) + + + def post_dump( +@@ -176,7 +176,7 @@ + ``partial`` and ``many`` are always passed as keyword arguments to + the decorated method. + """ +- return set_hook(fn, PRE_LOAD, many=not pass_many) ++ return set_hook(fn, PRE_LOAD, many=pass_many) + + + def post_load( diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9de6c852eab0bb40ca52ef7480101c87a3ddabbf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/solution/solve.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/decorators.py b/src/marshmallow/decorators.py +index a28d791a2b025919f6a61e6a9b7171d5b904052d..965edb68b7ddd2eeaba41aa49e51d2dd7c2440db 100644 +--- a/src/marshmallow/decorators.py ++++ b/src/marshmallow/decorators.py +@@ -138,7 +138,7 @@ + .. versionchanged:: 3.0.0 + ``many`` is always passed as a keyword arguments to the decorated method. + """ +- return set_hook(fn, PRE_DUMP, many=not pass_many) ++ return set_hook(fn, PRE_DUMP, many=pass_many) + + + def post_dump( +@@ -176,7 +176,7 @@ + ``partial`` and ``many`` are always passed as keyword arguments to + the decorated method. + """ +- return set_hook(fn, PRE_LOAD, many=not pass_many) ++ return set_hook(fn, PRE_LOAD, many=pass_many) + + + def post_load( +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..685594154fdbc54c363b93397c0476545cf0091a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:dadf346aa7583df28f7362f4f12dd5f288054e0084c64feab2d560e0da5c1303" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d9feb9b8e64929c14cabb3da9fb97cfebe488b6e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..aee50db50ca6373ffe746818305a13b92db81a9e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/decorators.py b/src/marshmallow/decorators.py +index a28d791a2b025919f6a61e6a9b7171d5b904052d..965edb68b7ddd2eeaba41aa49e51d2dd7c2440db 100644 +--- a/src/marshmallow/decorators.py ++++ b/src/marshmallow/decorators.py +@@ -138,7 +138,7 @@ + .. versionchanged:: 3.0.0 + ``many`` is always passed as a keyword arguments to the decorated method. + """ +- return set_hook(fn, PRE_DUMP, many=not pass_many) ++ return set_hook(fn, PRE_DUMP, many=pass_many) + + + def post_dump( +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__ngnyfe96/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..a06959cf82e0edf83149f9184873b83ac8e7fdc9 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "31f46b85953bbee59d90778c9fabef0a5d99973ed2b184bf4af4f4e41de21e0f", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "aa4b113aff793942cf3400d9fb15b0b1aa7c71c11528b7e710529721e60fe62a", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "20010e3739692b69edc92b889b0888abb5a15fbc053ecfa6951b733a02e825e2", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "e7c7b8fc1172cb46de52b94bb06e6a61ace6749d", + "source_completion_sha256": "82be54c6dc781afe283b21676bad98c49a7e1d19ca8a8be507212dfd6271d96d", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "cd9d24cb600b866f5a549f13c4bed7b8a1bbca514fb281333e9772d093d161ba", + "is_fork": true, + "learner_path": "tasks/b649763d851e074a4a118add/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e7c7b8fc1172cb46de52b94bb06e6a61ace6749d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "2cd81ee54d5f5d1333200fed1d4294ae80a1a076820ab5efe3e11b9b6d390fb8", + "provenance_path": "tasks/b649763d851e074a4a118add/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e7c7b8fc1172cb46de52b94bb06e6a61ace6749d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "50b545bedc3eb2c8c1ea4010c3ee2e150b466486", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "task_sha256": "154f574c0225913479e9204f9822032ecead7c38ba64b17e36a63c30e5c0b3cc", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..ade5c4cb8f19629d99774a1b1442c578d48ec15e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/instruction.md @@ -0,0 +1,34 @@ +OneOf validator raises error for valid values + +#### Description + +The OneOf validator is incorrectly raising ValidationError for values that should be valid. When a value is present in the choices list, it should pass validation, but instead it's throwing an error saying the value must be one of the allowed choices. + +#### Steps/Code to Reproduce + +```python +from marshmallow import validate + +# This should pass but raises ValidationError +validator = validate.OneOf([1, 2, 3]) +validator(2) # Should return 2, but raises ValidationError: Must be one of: 1, 2, 3. + +# Same issue with custom message +validator_custom = validate.OneOf([1, 2, 3], error="Custom error message") +validator_custom(1) # Should return 1, but doesn't raise expected ValidationError +``` + +Also affects ContainsOnly validator which returns truncated results: + +```python +from marshmallow import validate + +validator = validate.ContainsOnly([1, 2, 3]) +result = validator([1, 2]) # Should return [1, 2], but returns [1] (missing last element) +``` + +The URL validator with `require_tld=False` is also affected and rejects valid URLs that should be accepted when TLD requirement is disabled. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..d3eb3d5d98628a89389679b77d89cddd08d6958a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "50b545bedc3eb2c8c1ea4010c3ee2e150b466486", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "e7c7b8fc1172cb46de52b94bb06e6a61ace6749d" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_schema.py", + "tests/test_validate.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/validate.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2213556, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "cd9d24cb600b866f5a549f13c4bed7b8a1bbca514fb281333e9772d093d161ba", + "is_fork": true, + "learner_path": "tasks/b649763d851e074a4a118add/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e7c7b8fc1172cb46de52b94bb06e6a61ace6749d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "2cd81ee54d5f5d1333200fed1d4294ae80a1a076820ab5efe3e11b9b6d390fb8", + "provenance_path": "tasks/b649763d851e074a4a118add/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e7c7b8fc1172cb46de52b94bb06e6a61ace6749d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "50b545bedc3eb2c8c1ea4010c3ee2e150b466486", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "task_sha256": "154f574c0225913479e9204f9822032ecead7c38ba64b17e36a63c30e5c0b3cc", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..21f08b284ad1e3102068037aaa044fa3fdc2ad9f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "31f46b85953bbee59d90778c9fabef0a5d99973ed2b184bf4af4f4e41de21e0f", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e7c7b8fc1172cb46de52b94bb06e6a61ace6749d/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "82be54c6dc781afe283b21676bad98c49a7e1d19ca8a8be507212dfd6271d96d", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "e2f3089143abe7fbb7510dadfebaf7b05ea2e494d5541806ff9c7d85342a3e50", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "cd9d24cb600b866f5a549f13c4bed7b8a1bbca514fb281333e9772d093d161ba", + "is_fork": true, + "learner_path": "tasks/b649763d851e074a4a118add/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e7c7b8fc1172cb46de52b94bb06e6a61ace6749d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "2cd81ee54d5f5d1333200fed1d4294ae80a1a076820ab5efe3e11b9b6d390fb8", + "provenance_path": "tasks/b649763d851e074a4a118add/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e7c7b8fc1172cb46de52b94bb06e6a61ace6749d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "50b545bedc3eb2c8c1ea4010c3ee2e150b466486", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg", + "task_sha256": "154f574c0225913479e9204f9822032ecead7c38ba64b17e36a63c30e5c0b3cc", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..b0a846dd198badca180dbf2affce6ea2bb63de4c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/provided-gold.diff @@ -0,0 +1,53 @@ +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 39abd15c6ffc7bb7401f278c2e79a611d5d5dd67..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,12 +163,12 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: +- key = (absolute, relative, require_tld) ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( +- relative, absolute, not require_tld ++ relative, absolute, require_tld + ) +- ++ + return self._memoized[key] + + _regex = RegexMemoizer() +@@ -597,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -647,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d753ddf101cd3156380b1ec9c2ffa40044f8aca --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/solution/solve.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 39abd15c6ffc7bb7401f278c2e79a611d5d5dd67..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,12 +163,12 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: +- key = (absolute, relative, require_tld) ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( +- relative, absolute, not require_tld ++ relative, absolute, require_tld + ) +- ++ + return self._memoized[key] + + _regex = RegexMemoizer() +@@ -597,12 +597,12 @@ + + def __call__(self, value: typing.Any) -> typing.Any: + try: +- if value in self.choices: ++ if value not in self.choices: + raise ValidationError(self._format_error(value)) +- except TypeError: +- pass +- +- return None ++ except TypeError as error: ++ raise ValidationError(self._format_error(value)) from error ++ ++ return value + + def options( + self, +@@ -647,11 +647,11 @@ + return super()._format_error(value_text) + + def __call__(self, value: typing.Sequence[_T]) -> typing.Sequence[_T]: +- reversed_choices = list(reversed(self.choices)) ++ # We can't use set.issubset because does not handle unhashable types + for val in value: +- if val not in reversed_choices: ++ if val not in self.choices: + raise ValidationError(self._format_error(value)) +- return value[:-1] ++ return value + + + class ContainsNoneOf(NoneOf): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..39fd368665fe1c509117bce8d293e0efe2c80624 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:63ad4de7940039ecd3a5e3e33e38c534ce364563de432edb82a4eff44ee7ece2" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..73ee12921d6935f868a509030f12e18e5623334e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ec493b54f20c32255a7570d0828186e33b26b1c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/first-hunk-only.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/validate.py b/src/marshmallow/validate.py +index 39abd15c6ffc7bb7401f278c2e79a611d5d5dd67..e4536d88c4d4481e82c21d8757436653e59577e5 100644 +--- a/src/marshmallow/validate.py ++++ b/src/marshmallow/validate.py +@@ -163,12 +163,12 @@ + def __call__( + self, relative: bool, absolute: bool, require_tld: bool + ) -> typing.Pattern: +- key = (absolute, relative, require_tld) ++ key = (relative, absolute, require_tld) + if key not in self._memoized: + self._memoized[key] = self._regex_generator( +- relative, absolute, not require_tld ++ relative, absolute, require_tld + ) +- ++ + return self._memoized[key] + + _regex = RegexMemoizer() +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__qm86nytg/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..efb11a1b89f2815d257f650cea5b4c3da7528e1a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "074a65bdc7fdb5f883dc4b5bef62ce31cd7bbcde112f025fc8e67c86e0e528bf", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "653bc685f62924aa37028059822be64414ee09062b382c580318ba822b22d27b", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "713f751fe018b980af648f22345dde0517f9a21f69e1cf9391a087283a5f68d1", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "e1443961bbed9ede695c1b3c4d38c050a4ef060c", + "source_completion_sha256": "c75da0e2be3a8a178c5433d50ecf56ad2ef58cfed3048ef4cce4ca189df1535c", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "45a96065216a3b4882de7b7529a1016e3b58146a99ab0500ecaa183ff55df6d1", + "is_fork": true, + "learner_path": "tasks/93f335c1e2564b7696f04c93/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e1443961bbed9ede695c1b3c4d38c050a4ef060c/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b459f5ecb3fb83e587f84ab5fc9f3776a15c1d072391fac56ef1671b302c24cc", + "provenance_path": "tasks/93f335c1e2564b7696f04c93/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e1443961bbed9ede695c1b3c4d38c050a4ef060c", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "86b6d8ec412c699294fc1ab52cec18a9c6d1fa90", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "task_sha256": "6167d407b90b1a0912a5a6e52695b731a5de244f9c184d090beb8f114a007294", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..cd177a23b3be4e7f31dae4884e210ab57a44c4f4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/instruction.md @@ -0,0 +1,68 @@ +# Schema validation and deserialization broken in multiple ways + +## Minimal example + +```python +from marshmallow import Schema, fields, ValidationError + +class UserSchema(Schema): + name = fields.String(required=True) + age = fields.Integer() + +# This used to work but now fails +schema = UserSchema() +try: + result = schema.load({"age": 30}) # Missing required field 'name' + print("Loaded:", result) +except ValidationError as e: + print("Error:", e.messages) # Should show error for missing 'name' field + +# This also fails +schema_many = UserSchema(many=True) +try: + result = schema_many.load([{"name": "John", "age": "25"}, {"name": "Jane", "age": "30"}]) + print("Loaded many:", result) # Should convert string ages to integers +except ValidationError as e: + print("Error:", e.messages) + +# dumps is also broken +try: + json_str = schema.dumps({"name": "John", "age": 30}) + print("Dumped:", json_str) +except Exception as e: + print("Dump error:", str(e)) +``` + +## Problem description + +After a recent update, there are multiple issues with schema validation and deserialization: + +1. Required fields aren't properly validated - the validation errors aren't being stored correctly +2. Type coercion isn't working properly during deserialization +3. The `many=True` parameter doesn't work correctly when deserializing collections +4. The `dumps` method is passing incorrect parameters to the render module +5. There seems to be an undefined `Iterable` reference causing errors + +The code that used to work fine is now failing in multiple ways. The validation errors aren't being properly collected, and the deserialized data doesn't contain the expected values. + +## Expected behavior + +- Required fields should raise validation errors when missing +- Type coercion should work (e.g., string "25" should be converted to integer 25) +- Collection deserialization with `many=True` should work correctly +- The `dumps` method should correctly serialize objects to JSON +- No undefined references should be present + +## Actual behavior + +- Required field validation is broken +- Type coercion isn't working +- Collection deserialization fails +- The `dumps` method raises errors about unexpected keyword arguments +- There are undefined references causing errors + +I'm using marshmallow 3.x and Python 3.10. This seems to be a regression from a previous working version. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..70c411e8963c0bc314a5c0d2dbef79eb6b669124 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_utils.py::test_function_field_using_type_annotation" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "86b6d8ec412c699294fc1ab52cec18a9c6d1fa90", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "e1443961bbed9ede695c1b3c4d38c050a4ef060c" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_decorators.py", + "tests/test_deserialization.py", + "tests/test_fields.py", + "tests/test_options.py", + "tests/test_schema.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/schema.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2174300, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "45a96065216a3b4882de7b7529a1016e3b58146a99ab0500ecaa183ff55df6d1", + "is_fork": true, + "learner_path": "tasks/93f335c1e2564b7696f04c93/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e1443961bbed9ede695c1b3c4d38c050a4ef060c/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b459f5ecb3fb83e587f84ab5fc9f3776a15c1d072391fac56ef1671b302c24cc", + "provenance_path": "tasks/93f335c1e2564b7696f04c93/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e1443961bbed9ede695c1b3c4d38c050a4ef060c", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "86b6d8ec412c699294fc1ab52cec18a9c6d1fa90", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "task_sha256": "6167d407b90b1a0912a5a6e52695b731a5de244f9c184d090beb8f114a007294", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..552165a0148137517a59e9cd0b219e97973dc25d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "074a65bdc7fdb5f883dc4b5bef62ce31cd7bbcde112f025fc8e67c86e0e528bf", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e1443961bbed9ede695c1b3c4d38c050a4ef060c/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "c75da0e2be3a8a178c5433d50ecf56ad2ef58cfed3048ef4cce4ca189df1535c", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "e09992af963e843273c64c8960d13677e72b9e0a04dd8e1d2db7008e7f14d465", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "45a96065216a3b4882de7b7529a1016e3b58146a99ab0500ecaa183ff55df6d1", + "is_fork": true, + "learner_path": "tasks/93f335c1e2564b7696f04c93/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/e1443961bbed9ede695c1b3c4d38c050a4ef060c/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b459f5ecb3fb83e587f84ab5fc9f3776a15c1d072391fac56ef1671b302c24cc", + "provenance_path": "tasks/93f335c1e2564b7696f04c93/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e1443961bbed9ede695c1b3c4d38c050a4ef060c", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "86b6d8ec412c699294fc1ab52cec18a9c6d1fa90", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq", + "task_sha256": "6167d407b90b1a0912a5a6e52695b731a5de244f9c184d090beb8f114a007294", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..750e49d014c3732e688deb345a2a3d79885a9a6c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/provided-gold.diff @@ -0,0 +1,163 @@ +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 44d873ed86a6945a86d6a86ca86424adde4916f8..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -83,25 +83,35 @@ + """ + + def __new__(mcs, name, bases, attrs): +- meta = attrs.get("Meta", None) ++ meta = attrs.get("Meta") + ordered = getattr(meta, "ordered", False) + if not ordered: ++ # Inherit 'ordered' option ++ # Warning: We loop through bases instead of MRO because we don't ++ # yet have access to the class object ++ # (i.e. can't call super before we have fields) + for base_ in bases: + if hasattr(base_, "Meta") and hasattr(base_.Meta, "ordered"): + ordered = base_.Meta.ordered + break + else: +- ordered = True ++ ordered = False + cls_fields = _get_fields(attrs) ++ # Remove fields from list of class attributes to avoid shadowing ++ # Schema attributes/methods in case of name conflict + for field_name, _ in cls_fields: +- attrs.pop(field_name, None) # Changed from del to pop ++ del attrs[field_name] + klass = super().__new__(mcs, name, bases, attrs) + inherited_fields = _get_fields_by_mro(klass) + +- meta = getattr(klass, "Meta", None) +- klass.opts = klass.OPTIONS_CLASS(meta, ordered=not ordered) # Negated ordered +- cls_fields.extend(klass.opts.include.items()) # Changed += to extend +- ++ meta = klass.Meta ++ # Set klass.opts in __new__ rather than __init__ so that it is accessible in ++ # get_declared_fields ++ klass.opts = klass.OPTIONS_CLASS(meta, ordered=ordered) ++ # Add fields specified in the `include` class Meta option ++ cls_fields += list(klass.opts.include.items()) ++ ++ # Assign _declared_fields on class + klass._declared_fields = mcs.get_declared_fields( + klass=klass, + cls_fields=cls_fields, +@@ -561,8 +571,8 @@ + A :exc:`ValidationError ` is raised + if ``obj`` is invalid. + """ +- serialized = self.dump(obj, many=None) +- return self.opts.render_module.dumps(serialized, many=many, **kwargs) ++ serialized = self.dump(obj, many=many) ++ return self.opts.render_module.dumps(serialized, *args, **kwargs) + + def _deserialize( + self, +@@ -593,43 +603,42 @@ + :return: The deserialized data as `dict_class` instance or list of `dict_class` + instances if `many` is `True`. + """ +- index_errors = not self.opts.index_errors ++ index_errors = self.opts.index_errors + index = index if index_errors else None + if many: +- if is_collection(data): ++ if not is_collection(data): ++ error_store.store_error([self.error_messages["type"]], index=index) + ret_l = [] +- for d in data: ++ else: ++ ret_l = [ + self._deserialize( + typing.cast(dict, d), + error_store=error_store, + many=False, + partial=partial, + unknown=unknown, +- index=index, ++ index=idx, + ) +- else: +- error_store.store_error([self.error_messages["type"]], index=index) +- ret_l = [] ++ for idx, d in enumerate(data) ++ ] + return ret_l + ret_d = self.dict_class() + # Check data is a dict +- if not isinstance(data, Iterable): ++ if not isinstance(data, Mapping): + error_store.store_error([self.error_messages["type"]], index=index) + else: + partial_is_collection = is_collection(partial) + for attr_name, field_obj in self.load_fields.items(): + field_name = ( +- attr_name if field_obj.data_key is None else field_obj.data_key ++ field_obj.data_key if field_obj.data_key is not None else attr_name + ) +- raw_value = data.get(field_name, None) ++ raw_value = data.get(field_name, missing) + if raw_value is missing: + # Ignore missing field if we're allowed to. +- if partial is False or ( +- partial_is_collection and attr_name not in partial ++ if partial is True or ( ++ partial_is_collection and attr_name in partial + ): + continue +- if unknown == INCLUDE and partial: +- continue + d_kwargs = {} + # Allow partial loading of nested schemas. + if partial_is_collection: +@@ -639,6 +648,8 @@ + f[len_prefix:] for f in partial if f.startswith(prefix) + ] + d_kwargs["partial"] = sub_partial ++ elif partial is not None: ++ d_kwargs["partial"] = partial + + def getter( + val, field_obj=field_obj, field_name=field_name, d_kwargs=d_kwargs +@@ -657,16 +668,16 @@ + error_store=error_store, + index=index, + ) +- if value is not None: +- key = field_obj.data_key or attr_name ++ if value is not missing: ++ key = field_obj.attribute or attr_name + set_value(ret_d, key, value) +- if unknown == EXCLUDE: ++ if unknown != EXCLUDE: + fields = { + field_obj.data_key if field_obj.data_key is not None else field_name + for field_name, field_obj in self.load_fields.items() + } +- for key in set(data) & fields: +- value = key ++ for key in set(data) - fields: ++ value = data[key] + if unknown == INCLUDE: + ret_d[key] = value + elif unknown == RAISE: +@@ -757,12 +768,12 @@ + index=None, + ): + try: +- if not pass_original: # Incorrect logic reversal for passing original data +- validator_func(output, partial=many, many=partial) # Swap partial and many ++ if pass_original: # Pass original, raw data (before unmarshalling) ++ validator_func(output, original_data, partial=partial, many=many) + else: +- validator_func(output, original_data, partial=many, many=partial) # Swap partial and many ++ validator_func(output, partial=partial, many=many) + except ValidationError as err: +- pass # Swallow exceptions silently, no error stored ++ error_store.store_error(err.messages, err.field_name, index=index) + + def validate( + self, diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..45917871625f3d39221366b9aed68c7cd43f04a3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/solution/solve.sh @@ -0,0 +1,169 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 44d873ed86a6945a86d6a86ca86424adde4916f8..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -83,25 +83,35 @@ + """ + + def __new__(mcs, name, bases, attrs): +- meta = attrs.get("Meta", None) ++ meta = attrs.get("Meta") + ordered = getattr(meta, "ordered", False) + if not ordered: ++ # Inherit 'ordered' option ++ # Warning: We loop through bases instead of MRO because we don't ++ # yet have access to the class object ++ # (i.e. can't call super before we have fields) + for base_ in bases: + if hasattr(base_, "Meta") and hasattr(base_.Meta, "ordered"): + ordered = base_.Meta.ordered + break + else: +- ordered = True ++ ordered = False + cls_fields = _get_fields(attrs) ++ # Remove fields from list of class attributes to avoid shadowing ++ # Schema attributes/methods in case of name conflict + for field_name, _ in cls_fields: +- attrs.pop(field_name, None) # Changed from del to pop ++ del attrs[field_name] + klass = super().__new__(mcs, name, bases, attrs) + inherited_fields = _get_fields_by_mro(klass) + +- meta = getattr(klass, "Meta", None) +- klass.opts = klass.OPTIONS_CLASS(meta, ordered=not ordered) # Negated ordered +- cls_fields.extend(klass.opts.include.items()) # Changed += to extend +- ++ meta = klass.Meta ++ # Set klass.opts in __new__ rather than __init__ so that it is accessible in ++ # get_declared_fields ++ klass.opts = klass.OPTIONS_CLASS(meta, ordered=ordered) ++ # Add fields specified in the `include` class Meta option ++ cls_fields += list(klass.opts.include.items()) ++ ++ # Assign _declared_fields on class + klass._declared_fields = mcs.get_declared_fields( + klass=klass, + cls_fields=cls_fields, +@@ -561,8 +571,8 @@ + A :exc:`ValidationError ` is raised + if ``obj`` is invalid. + """ +- serialized = self.dump(obj, many=None) +- return self.opts.render_module.dumps(serialized, many=many, **kwargs) ++ serialized = self.dump(obj, many=many) ++ return self.opts.render_module.dumps(serialized, *args, **kwargs) + + def _deserialize( + self, +@@ -593,43 +603,42 @@ + :return: The deserialized data as `dict_class` instance or list of `dict_class` + instances if `many` is `True`. + """ +- index_errors = not self.opts.index_errors ++ index_errors = self.opts.index_errors + index = index if index_errors else None + if many: +- if is_collection(data): ++ if not is_collection(data): ++ error_store.store_error([self.error_messages["type"]], index=index) + ret_l = [] +- for d in data: ++ else: ++ ret_l = [ + self._deserialize( + typing.cast(dict, d), + error_store=error_store, + many=False, + partial=partial, + unknown=unknown, +- index=index, ++ index=idx, + ) +- else: +- error_store.store_error([self.error_messages["type"]], index=index) +- ret_l = [] ++ for idx, d in enumerate(data) ++ ] + return ret_l + ret_d = self.dict_class() + # Check data is a dict +- if not isinstance(data, Iterable): ++ if not isinstance(data, Mapping): + error_store.store_error([self.error_messages["type"]], index=index) + else: + partial_is_collection = is_collection(partial) + for attr_name, field_obj in self.load_fields.items(): + field_name = ( +- attr_name if field_obj.data_key is None else field_obj.data_key ++ field_obj.data_key if field_obj.data_key is not None else attr_name + ) +- raw_value = data.get(field_name, None) ++ raw_value = data.get(field_name, missing) + if raw_value is missing: + # Ignore missing field if we're allowed to. +- if partial is False or ( +- partial_is_collection and attr_name not in partial ++ if partial is True or ( ++ partial_is_collection and attr_name in partial + ): + continue +- if unknown == INCLUDE and partial: +- continue + d_kwargs = {} + # Allow partial loading of nested schemas. + if partial_is_collection: +@@ -639,6 +648,8 @@ + f[len_prefix:] for f in partial if f.startswith(prefix) + ] + d_kwargs["partial"] = sub_partial ++ elif partial is not None: ++ d_kwargs["partial"] = partial + + def getter( + val, field_obj=field_obj, field_name=field_name, d_kwargs=d_kwargs +@@ -657,16 +668,16 @@ + error_store=error_store, + index=index, + ) +- if value is not None: +- key = field_obj.data_key or attr_name ++ if value is not missing: ++ key = field_obj.attribute or attr_name + set_value(ret_d, key, value) +- if unknown == EXCLUDE: ++ if unknown != EXCLUDE: + fields = { + field_obj.data_key if field_obj.data_key is not None else field_name + for field_name, field_obj in self.load_fields.items() + } +- for key in set(data) & fields: +- value = key ++ for key in set(data) - fields: ++ value = data[key] + if unknown == INCLUDE: + ret_d[key] = value + elif unknown == RAISE: +@@ -757,12 +768,12 @@ + index=None, + ): + try: +- if not pass_original: # Incorrect logic reversal for passing original data +- validator_func(output, partial=many, many=partial) # Swap partial and many ++ if pass_original: # Pass original, raw data (before unmarshalling) ++ validator_func(output, original_data, partial=partial, many=many) + else: +- validator_func(output, original_data, partial=many, many=partial) # Swap partial and many ++ validator_func(output, partial=partial, many=many) + except ValidationError as err: +- pass # Swallow exceptions silently, no error stored ++ error_store.store_error(err.messages, err.field_name, index=index) + + def validate( + self, +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6d8c2d2268d224210567181f25dde2215102fefc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:d4a473ecfd7495ba4bda8163818e66e5f7f35be658c62060c884a378599b0bc5" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..e5e44494bb89c03e6e786c491df2b1e6c3ab5a8d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_utils.py::test_function_field_using_type_annotation" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fb324c19b0865705b1fb030719e898e97f58fcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/first-hunk-only.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 44d873ed86a6945a86d6a86ca86424adde4916f8..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -83,25 +83,35 @@ + """ + + def __new__(mcs, name, bases, attrs): +- meta = attrs.get("Meta", None) ++ meta = attrs.get("Meta") + ordered = getattr(meta, "ordered", False) + if not ordered: ++ # Inherit 'ordered' option ++ # Warning: We loop through bases instead of MRO because we don't ++ # yet have access to the class object ++ # (i.e. can't call super before we have fields) + for base_ in bases: + if hasattr(base_, "Meta") and hasattr(base_.Meta, "ordered"): + ordered = base_.Meta.ordered + break + else: +- ordered = True ++ ordered = False + cls_fields = _get_fields(attrs) ++ # Remove fields from list of class attributes to avoid shadowing ++ # Schema attributes/methods in case of name conflict + for field_name, _ in cls_fields: +- attrs.pop(field_name, None) # Changed from del to pop ++ del attrs[field_name] + klass = super().__new__(mcs, name, bases, attrs) + inherited_fields = _get_fields_by_mro(klass) + +- meta = getattr(klass, "Meta", None) +- klass.opts = klass.OPTIONS_CLASS(meta, ordered=not ordered) # Negated ordered +- cls_fields.extend(klass.opts.include.items()) # Changed += to extend +- ++ meta = klass.Meta ++ # Set klass.opts in __new__ rather than __init__ so that it is accessible in ++ # get_declared_fields ++ klass.opts = klass.OPTIONS_CLASS(meta, ordered=ordered) ++ # Add fields specified in the `include` class Meta option ++ cls_fields += list(klass.opts.include.items()) ++ ++ # Assign _declared_fields on class + klass._declared_fields = mcs.get_declared_fields( + klass=klass, + cls_fields=cls_fields, +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__r3bsyxuq/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..ab239dfc571a000f3f819f7f6c368ff2ae5fac73 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "45665867e126a54ab7f39575adaa8c37f19bf09d6d138d3e5a655bd87d527c0c", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "65a87c25727bf76a9651612520f00e64ff73b8fd08fa6cdc3f3e21ed98330dba", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "1c730937adb171838395c132e76343900088fc5b98d5de477bb63d2a22d3e813", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "b8b1c3908669abe60d5d4df36302fc24769a23ea", + "source_completion_sha256": "981e8bd3bdfab85e1b7687106b0935460a0f77c72143beab5f72e549ebde85a3", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "6fe17adcf987d6ebc02aae8eb53863c3dca6e568c92b4996cfc08f458f62a6c3", + "is_fork": true, + "learner_path": "tasks/97557ce6f75f30cec0652fa7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/b8b1c3908669abe60d5d4df36302fc24769a23ea/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a457a3848bf2761097baffdf0fb52e0c5406de7a4b06c797d9a1fb001e928ce9", + "provenance_path": "tasks/97557ce6f75f30cec0652fa7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b8b1c3908669abe60d5d4df36302fc24769a23ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "7ee85cfd5d3eb69e1494c89af1d4f670f0919f4f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "task_sha256": "4f66fe0e29b2396028e71a71335ae5e7fd3be9c631ffa782294df2c81edeacb6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..da217588de1b94af97b77efed685d7b7a7803336 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/instruction.md @@ -0,0 +1,44 @@ +DateTime serialization returns truncated ISO format + +#### Description + +When serializing datetime objects, the output is unexpectedly truncated to only show hours and minutes, omitting seconds and microseconds from the ISO format string. + +#### Steps/Code to Reproduce + +```python +from datetime import datetime +from marshmallow import Schema, fields + +# Create a datetime with seconds and microseconds +dt = datetime(2013, 11, 10, 1, 23, 45, 123456) + +# Try to serialize it +class TestSchema(Schema): + timestamp = fields.DateTime() + +schema = TestSchema() +result = schema.dump({'timestamp': dt}) +print(f"Expected: 2013-11-10T01:23:45.123456") +print(f"Actual: {result['timestamp']}") +``` + +The output shows only `2013-11-10T01:23` instead of the full `2013-11-10T01:23:45.123456`. + +This also affects timezone-aware datetimes: + +```python +from datetime import datetime, timezone + +# With timezone +dt_tz = datetime(2013, 11, 10, 1, 23, 45, tzinfo=timezone.utc) +result_tz = schema.dump({'timestamp': dt_tz}) +print(f"Expected: 2013-11-10T01:23:45+00:00") +print(f"Actual: {result_tz['timestamp']}") +``` + +Shows `2013-11-10T01:23+00:00` instead of `2013-11-10T01:23:45+00:00`. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..86790a58a53d3b93b38c3bf58c1322c1bb7da45a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "7ee85cfd5d3eb69e1494c89af1d4f670f0919f4f", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "b8b1c3908669abe60d5d4df36302fc24769a23ea" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_error_store.py", + "tests/test_serialization.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/utils.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2287386, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "6fe17adcf987d6ebc02aae8eb53863c3dca6e568c92b4996cfc08f458f62a6c3", + "is_fork": true, + "learner_path": "tasks/97557ce6f75f30cec0652fa7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/b8b1c3908669abe60d5d4df36302fc24769a23ea/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a457a3848bf2761097baffdf0fb52e0c5406de7a4b06c797d9a1fb001e928ce9", + "provenance_path": "tasks/97557ce6f75f30cec0652fa7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b8b1c3908669abe60d5d4df36302fc24769a23ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "7ee85cfd5d3eb69e1494c89af1d4f670f0919f4f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "task_sha256": "4f66fe0e29b2396028e71a71335ae5e7fd3be9c631ffa782294df2c81edeacb6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..45c822e1d20dd1fd8cdbd5a990d447414378c27f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "45665867e126a54ab7f39575adaa8c37f19bf09d6d138d3e5a655bd87d527c0c", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/b8b1c3908669abe60d5d4df36302fc24769a23ea/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "981e8bd3bdfab85e1b7687106b0935460a0f77c72143beab5f72e549ebde85a3", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "906e08c30d1160e5340af9a937c3cd5646fa9e265cb0fd98b2c31b650356f06a", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "6fe17adcf987d6ebc02aae8eb53863c3dca6e568c92b4996cfc08f458f62a6c3", + "is_fork": true, + "learner_path": "tasks/97557ce6f75f30cec0652fa7/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/b8b1c3908669abe60d5d4df36302fc24769a23ea/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a457a3848bf2761097baffdf0fb52e0c5406de7a4b06c797d9a1fb001e928ce9", + "provenance_path": "tasks/97557ce6f75f30cec0652fa7/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b8b1c3908669abe60d5d4df36302fc24769a23ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "7ee85cfd5d3eb69e1494c89af1d4f670f0919f4f", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961", + "task_sha256": "4f66fe0e29b2396028e71a71335ae5e7fd3be9c631ffa782294df2c81edeacb6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..d822ad9464e0e2fddeb5fa82cd59cbefb3bf60c8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/provided-gold.diff @@ -0,0 +1,42 @@ +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index a18984ab1a76582782007d97bea010505db02395..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -96,7 +96,7 @@ + # https://stackoverflow.com/a/27596917 + def is_aware(datetime: dt.datetime) -> bool: + return ( +- datetime.tzinfo is not None or datetime.tzinfo.utcoffset(datetime) is None ++ datetime.tzinfo is not None and datetime.tzinfo.utcoffset(datetime) is not None + ) + + +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + +@@ -232,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2699eb5ef314ab6ec1bad3c501cda733c2717646 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/solution/solve.sh @@ -0,0 +1,48 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index a18984ab1a76582782007d97bea010505db02395..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -96,7 +96,7 @@ + # https://stackoverflow.com/a/27596917 + def is_aware(datetime: dt.datetime) -> bool: + return ( +- datetime.tzinfo is not None or datetime.tzinfo.utcoffset(datetime) is None ++ datetime.tzinfo is not None and datetime.tzinfo.utcoffset(datetime) is not None + ) + + +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + +@@ -232,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3249a6e1c1a188e5b1b9b16b3bae44b61791039d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:08691dff244f78d280ffdd49af1614b7bf408a62c5d39ac796cf6b7963693505" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..e2660537174fc4ab20bfcf95c025c7a8157306d1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..94110c5bd55acbfaf1478ebf3290b3bfe243bd18 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index a18984ab1a76582782007d97bea010505db02395..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__rn6f9961/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..fa5a69fe662308349e585e6e61833933f423224f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "213d054f3495a88fa629833c002561eff5fd67b1eeacef35a9d7c14036398671", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "480c13cbd982d0c1b37b2836ce5d91b47f6a576370c221261f9e9dca9b52dff9", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "2949c2bf22c2f2178e6dd16ff3127bfc2c88f97b7c1903ae2a380d84d4a6b70f", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "6332537ad32834d4faee2b4f0e8e6c65d2dc5277", + "source_completion_sha256": "07052d1956b0a7cc3f7d1522a309b6a5bec1160aabdcc518af37a9a4e79ac6a6", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "10022ed86dab916ee99691587ea645e2f186612380995c1d806c005af3d34499", + "is_fork": true, + "learner_path": "tasks/7a99230488fe7d9a68ea6e89/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/6332537ad32834d4faee2b4f0e8e6c65d2dc5277/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a6b572af264b9509a0f9d1596c6886ba94edf8ae8e2ee7bd59ee038a270303a9", + "provenance_path": "tasks/7a99230488fe7d9a68ea6e89/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "6332537ad32834d4faee2b4f0e8e6c65d2dc5277", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d2e5f232b2cd3166733d8379b438e70f5143d2d9", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "task_sha256": "dbc154c4fb12e8b82b6ac79c5c99cdf8c7217a7ec5af0c32096a58c149a2ba6d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..29cdb5f0762030062dd3bbd9d42f9cec01d1e3b4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/instruction.md @@ -0,0 +1,42 @@ +DateTime field serialization truncates seconds and microseconds + +#### Description + +When serializing datetime objects, the output is unexpectedly truncated to only show hours and minutes, dropping the seconds and microseconds components. + +#### Steps/Code to Reproduce + +```python +import datetime as dt +from marshmallow import fields + +# Create a datetime field +field = fields.DateTime() + +# Test with a simple datetime +dt_obj = dt.datetime(2013, 11, 10, 1, 23, 45) +result = field.serialize('d', {'d': dt_obj}) +print(f"Expected: 2013-11-10T01:23:45") +print(f"Got: {result}") + +# Test with microseconds +dt_obj_micro = dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc) +result_micro = field.serialize('d', {'d': dt_obj_micro}) +print(f"Expected: 2013-11-10T01:23:45.123456+00:00") +print(f"Got: {result_micro}") +``` + +The output shows: +``` +Expected: 2013-11-10T01:23:45 +Got: 2013-11-10T01:23 + +Expected: 2013-11-10T01:23:45.123456+00:00 +Got: 2013-11-10T01:23+00:00 +``` + +This affects all datetime serialization regardless of the format parameter ('iso', 'iso8601', or None). + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad7762443402b76ca4bda5f2714357a387150c5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "d2e5f232b2cd3166733d8379b438e70f5143d2d9", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "6332537ad32834d4faee2b4f0e8e6c65d2dc5277" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_schema.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_deserialization.py", + "tests/test_error_store.py", + "tests/test_serialization.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/utils.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2287396, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "10022ed86dab916ee99691587ea645e2f186612380995c1d806c005af3d34499", + "is_fork": true, + "learner_path": "tasks/7a99230488fe7d9a68ea6e89/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/6332537ad32834d4faee2b4f0e8e6c65d2dc5277/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a6b572af264b9509a0f9d1596c6886ba94edf8ae8e2ee7bd59ee038a270303a9", + "provenance_path": "tasks/7a99230488fe7d9a68ea6e89/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "6332537ad32834d4faee2b4f0e8e6c65d2dc5277", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d2e5f232b2cd3166733d8379b438e70f5143d2d9", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "task_sha256": "dbc154c4fb12e8b82b6ac79c5c99cdf8c7217a7ec5af0c32096a58c149a2ba6d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..937d788e561911db0a596abc34c287a9838a6df4 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "213d054f3495a88fa629833c002561eff5fd67b1eeacef35a9d7c14036398671", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/6332537ad32834d4faee2b4f0e8e6c65d2dc5277/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "07052d1956b0a7cc3f7d1522a309b6a5bec1160aabdcc518af37a9a4e79ac6a6", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "43fcaf2205e3ba7b5065099fc5522d7d75b5c52f33be5800f275876889f778f9", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "10022ed86dab916ee99691587ea645e2f186612380995c1d806c005af3d34499", + "is_fork": true, + "learner_path": "tasks/7a99230488fe7d9a68ea6e89/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/6332537ad32834d4faee2b4f0e8e6c65d2dc5277/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "a6b572af264b9509a0f9d1596c6886ba94edf8ae8e2ee7bd59ee038a270303a9", + "provenance_path": "tasks/7a99230488fe7d9a68ea6e89/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "6332537ad32834d4faee2b4f0e8e6c65d2dc5277", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "d2e5f232b2cd3166733d8379b438e70f5143d2d9", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy", + "task_sha256": "dbc154c4fb12e8b82b6ac79c5c99cdf8c7217a7ec5af0c32096a58c149a2ba6d", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..ce22bc6cbda40f2bbe4633dfbe92b53d2d07b9c7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/provided-gold.diff @@ -0,0 +1,33 @@ +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index b0c4a054be49b08f6b74453e1c29c1ad2565e5ee..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + +@@ -232,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..68b6babbeef6083668c7af52030fd886e47bfc53 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/solution/solve.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index b0c4a054be49b08f6b74453e1c29c1ad2565e5ee..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +@@ -177,9 +177,8 @@ + if not match: + raise ValueError("Not a valid ISO8601-formatted time string") + kw = match.groupdict() +- kw["microsecond"] = kw["microsecond"] and kw["microsecond"].rjust(6, "0") ++ kw["microsecond"] = kw["microsecond"] and kw["microsecond"].ljust(6, "0") + kw = {k: int(v) for k, v in kw.items() if v is not None} +- kw["second"] += 1 if "second" in kw else 0 + return dt.time(**kw) + + +@@ -232,7 +231,7 @@ + + :param datetime datetime: The datetime. + """ +- return datetime.isoformat(timespec='minutes') ++ return datetime.isoformat() + + + def to_iso_time(time: dt.time) -> str: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..dedf454637757bd96c8ba4d5f16be96b92b0693f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:2b286df7a9fc572a2263eec36ff2d7b1ee562ff7ea09ec10590e1ab26a5086b1" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d0adc8af2b50f98aae9f04826cc86bc6b53093a5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..97b19430e728398170830d3adeb81d2d7c95bca8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py +index b0c4a054be49b08f6b74453e1c29c1ad2565e5ee..a5fe726243b16ed55660f75a5a30542a2faec8c2 100644 +--- a/src/marshmallow/utils.py ++++ b/src/marshmallow/utils.py +@@ -26,7 +26,7 @@ + + class _Missing: + def __bool__(self): +- return True ++ return False + + def __copy__(self): + return self +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__tf7zxjmy/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..2a7e07eab3e9043d676af180123b4f1f20138de8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "526de6004a8a39014e152c1dd03a9b2ca64c3b8758ee6317f7cc44b0d4c48ad4", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "430153f652abbdc81b2c9922d42a5606b95d20b2b9cac09eff0a73e8c51cf47e", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "d9cb9ccd6e01b757f8e0e9961ad6ece8a167f753f59d1a35d35d8d305578910a", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69", + "source_completion_sha256": "87e9a087849cf71237a428bd5485095a5dc9fa9ab7f920e3ae7e4341125bda30", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "a485f0dbdd64c2cc457ce160194a1da624af32cf3afeaf83404383008b26b7da", + "is_fork": true, + "learner_path": "tasks/8f7ec169341d60160297a5c9/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "68537fe70b5b9d26c7c45c8491e6e57f7fccaa732aba2ee2eb0964ccf2b0598d", + "provenance_path": "tasks/8f7ec169341d60160297a5c9/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "6759879db3b3e7d1bf4f71d5f980433ef5219ab2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "task_sha256": "b028c43a081180011c30d4099e137b7403bc29a1c32ead74d33d170de375b420", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..70c25d906b2a07f070b4f32b6f23a88897688fd9 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/instruction.md @@ -0,0 +1,34 @@ +Schema deserialization broken after recent changes + +#### Description + +Schema loading is completely broken - getting `NameError: name 'Iterable' is not defined` when trying to load any data with schemas. Also seeing issues with the `dumps` method getting unexpected keyword arguments. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields + +class UserSchema(Schema): + name = fields.Str() + email = fields.Email() + +schema = UserSchema() +data = {'name': 'John', 'email': 'john@example.com'} + +# This should work but raises NameError +result = schema.load(data) +``` + +Also having issues with dumps: + +```python +user = {'name': 'John', 'email': 'john@example.com'} +schema.dumps(user) # TypeError about unexpected 'many' keyword argument +``` + +The basic functionality of loading and dumping data with schemas seems to be completely broken. This affects pretty much any use of marshmallow schemas. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..de1f4e5ed665a9ad208aa55559c319d0507fde9a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_utils.py::test_function_field_using_type_annotation" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "6759879db3b3e7d1bf4f71d5f980433ef5219ab2", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_decorators.py", + "tests/test_deserialization.py", + "tests/test_fields.py", + "tests/test_options.py", + "tests/test_schema.py", + "tests/test_utils.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/schema.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2175176, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "a485f0dbdd64c2cc457ce160194a1da624af32cf3afeaf83404383008b26b7da", + "is_fork": true, + "learner_path": "tasks/8f7ec169341d60160297a5c9/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "68537fe70b5b9d26c7c45c8491e6e57f7fccaa732aba2ee2eb0964ccf2b0598d", + "provenance_path": "tasks/8f7ec169341d60160297a5c9/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "6759879db3b3e7d1bf4f71d5f980433ef5219ab2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "task_sha256": "b028c43a081180011c30d4099e137b7403bc29a1c32ead74d33d170de375b420", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f53b0b7038ff8dfb53229e018956814b69e960a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "526de6004a8a39014e152c1dd03a9b2ca64c3b8758ee6317f7cc44b0d4c48ad4", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "87e9a087849cf71237a428bd5485095a5dc9fa9ab7f920e3ae7e4341125bda30", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "62756dc4170122d602a995619005dac05909703f7cba991d778984937117d231", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "a485f0dbdd64c2cc457ce160194a1da624af32cf3afeaf83404383008b26b7da", + "is_fork": true, + "learner_path": "tasks/8f7ec169341d60160297a5c9/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "68537fe70b5b9d26c7c45c8491e6e57f7fccaa732aba2ee2eb0964ccf2b0598d", + "provenance_path": "tasks/8f7ec169341d60160297a5c9/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2d04047e65c64ddcc0fcd9fe9f1fe4bff39e3f69", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "6759879db3b3e7d1bf4f71d5f980433ef5219ab2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd", + "task_sha256": "b028c43a081180011c30d4099e137b7403bc29a1c32ead74d33d170de375b420", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..1a3a092596e09f1fe7128298fc1044d91af9cca8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/provided-gold.diff @@ -0,0 +1,103 @@ +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 5195cee61a07372f90e48a69dd626a3730b0e103..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -571,8 +571,8 @@ + A :exc:`ValidationError ` is raised + if ``obj`` is invalid. + """ +- serialized = self.dump(obj, many=None) +- return self.opts.render_module.dumps(serialized, many=many, **kwargs) ++ serialized = self.dump(obj, many=many) ++ return self.opts.render_module.dumps(serialized, *args, **kwargs) + + def _deserialize( + self, +@@ -603,43 +603,42 @@ + :return: The deserialized data as `dict_class` instance or list of `dict_class` + instances if `many` is `True`. + """ +- index_errors = not self.opts.index_errors ++ index_errors = self.opts.index_errors + index = index if index_errors else None + if many: +- if is_collection(data): ++ if not is_collection(data): ++ error_store.store_error([self.error_messages["type"]], index=index) + ret_l = [] +- for d in data: ++ else: ++ ret_l = [ + self._deserialize( + typing.cast(dict, d), + error_store=error_store, + many=False, + partial=partial, + unknown=unknown, +- index=index, ++ index=idx, + ) +- else: +- error_store.store_error([self.error_messages["type"]], index=index) +- ret_l = [] ++ for idx, d in enumerate(data) ++ ] + return ret_l + ret_d = self.dict_class() + # Check data is a dict +- if not isinstance(data, Iterable): ++ if not isinstance(data, Mapping): + error_store.store_error([self.error_messages["type"]], index=index) + else: + partial_is_collection = is_collection(partial) + for attr_name, field_obj in self.load_fields.items(): + field_name = ( +- attr_name if field_obj.data_key is None else field_obj.data_key ++ field_obj.data_key if field_obj.data_key is not None else attr_name + ) +- raw_value = data.get(field_name, None) ++ raw_value = data.get(field_name, missing) + if raw_value is missing: + # Ignore missing field if we're allowed to. +- if partial is False or ( +- partial_is_collection and attr_name not in partial ++ if partial is True or ( ++ partial_is_collection and attr_name in partial + ): + continue +- if unknown == INCLUDE and partial: +- continue + d_kwargs = {} + # Allow partial loading of nested schemas. + if partial_is_collection: +@@ -649,6 +648,8 @@ + f[len_prefix:] for f in partial if f.startswith(prefix) + ] + d_kwargs["partial"] = sub_partial ++ elif partial is not None: ++ d_kwargs["partial"] = partial + + def getter( + val, field_obj=field_obj, field_name=field_name, d_kwargs=d_kwargs +@@ -667,16 +668,16 @@ + error_store=error_store, + index=index, + ) +- if value is not None: +- key = field_obj.data_key or attr_name ++ if value is not missing: ++ key = field_obj.attribute or attr_name + set_value(ret_d, key, value) +- if unknown == EXCLUDE: ++ if unknown != EXCLUDE: + fields = { + field_obj.data_key if field_obj.data_key is not None else field_name + for field_name, field_obj in self.load_fields.items() + } +- for key in set(data) & fields: +- value = key ++ for key in set(data) - fields: ++ value = data[key] + if unknown == INCLUDE: + ret_d[key] = value + elif unknown == RAISE: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..85afeb314d8750c572149dae60771274f7281374 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/solution/solve.sh @@ -0,0 +1,109 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 5195cee61a07372f90e48a69dd626a3730b0e103..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -571,8 +571,8 @@ + A :exc:`ValidationError ` is raised + if ``obj`` is invalid. + """ +- serialized = self.dump(obj, many=None) +- return self.opts.render_module.dumps(serialized, many=many, **kwargs) ++ serialized = self.dump(obj, many=many) ++ return self.opts.render_module.dumps(serialized, *args, **kwargs) + + def _deserialize( + self, +@@ -603,43 +603,42 @@ + :return: The deserialized data as `dict_class` instance or list of `dict_class` + instances if `many` is `True`. + """ +- index_errors = not self.opts.index_errors ++ index_errors = self.opts.index_errors + index = index if index_errors else None + if many: +- if is_collection(data): ++ if not is_collection(data): ++ error_store.store_error([self.error_messages["type"]], index=index) + ret_l = [] +- for d in data: ++ else: ++ ret_l = [ + self._deserialize( + typing.cast(dict, d), + error_store=error_store, + many=False, + partial=partial, + unknown=unknown, +- index=index, ++ index=idx, + ) +- else: +- error_store.store_error([self.error_messages["type"]], index=index) +- ret_l = [] ++ for idx, d in enumerate(data) ++ ] + return ret_l + ret_d = self.dict_class() + # Check data is a dict +- if not isinstance(data, Iterable): ++ if not isinstance(data, Mapping): + error_store.store_error([self.error_messages["type"]], index=index) + else: + partial_is_collection = is_collection(partial) + for attr_name, field_obj in self.load_fields.items(): + field_name = ( +- attr_name if field_obj.data_key is None else field_obj.data_key ++ field_obj.data_key if field_obj.data_key is not None else attr_name + ) +- raw_value = data.get(field_name, None) ++ raw_value = data.get(field_name, missing) + if raw_value is missing: + # Ignore missing field if we're allowed to. +- if partial is False or ( +- partial_is_collection and attr_name not in partial ++ if partial is True or ( ++ partial_is_collection and attr_name in partial + ): + continue +- if unknown == INCLUDE and partial: +- continue + d_kwargs = {} + # Allow partial loading of nested schemas. + if partial_is_collection: +@@ -649,6 +648,8 @@ + f[len_prefix:] for f in partial if f.startswith(prefix) + ] + d_kwargs["partial"] = sub_partial ++ elif partial is not None: ++ d_kwargs["partial"] = partial + + def getter( + val, field_obj=field_obj, field_name=field_name, d_kwargs=d_kwargs +@@ -667,16 +668,16 @@ + error_store=error_store, + index=index, + ) +- if value is not None: +- key = field_obj.data_key or attr_name ++ if value is not missing: ++ key = field_obj.attribute or attr_name + set_value(ret_d, key, value) +- if unknown == EXCLUDE: ++ if unknown != EXCLUDE: + fields = { + field_obj.data_key if field_obj.data_key is not None else field_name + for field_name, field_obj in self.load_fields.items() + } +- for key in set(data) & fields: +- value = key ++ for key in set(data) - fields: ++ value = data[key] + if unknown == INCLUDE: + ret_d[key] = value + elif unknown == RAISE: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d82f2c9bff5bc4b3107044a67bb5eae61ebb18b9 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:c72c01eac41dae5aba1de42603fc725ba6b77bb3ca728eb862c952524d95be82" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..7657601fa485767e19cf13b3397bb1f9eb77cdc8 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_utils.py::test_function_field_using_type_annotation" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..976a889d1cbd01ed38ff5078cbff637ff3097361 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/first-hunk-only.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py +index 5195cee61a07372f90e48a69dd626a3730b0e103..e21768e9461e79664359a6c2b82fb578c6cf3655 100644 +--- a/src/marshmallow/schema.py ++++ b/src/marshmallow/schema.py +@@ -571,8 +571,8 @@ + A :exc:`ValidationError ` is raised + if ``obj`` is invalid. + """ +- serialized = self.dump(obj, many=None) +- return self.opts.render_module.dumps(serialized, many=many, **kwargs) ++ serialized = self.dump(obj, many=many) ++ return self.opts.render_module.dumps(serialized, *args, **kwargs) + + def _deserialize( + self, +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__v3hxvvcd/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..386fa0c79e459870c115fdc04abd5f317a5b850b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "d4ae534dfe959199aedaa30e83ee0f0bbc48d9cd55fa15f6d1c8c75fa05b434c", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "3c030d9f6c02d126bc9144cf512e7865a875ca49f1d0c07981e587dba508330f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "932c2903e750294a0c225f962209e4c6074ec803308c2d1062aff158dd510e95", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "4ff204b06ecb95509fa7b6307906e58f11eb596d", + "source_completion_sha256": "efd857d3792246f47bd3513867590fd8426bd42af3a24255935724276324b5b6", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "fb06cc840fdf572c7ad495b5f7b7f881558152295659d8c8a8f0c46516ba4d32", + "is_fork": true, + "learner_path": "tasks/ca0daba3c6a3901074207690/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/4ff204b06ecb95509fa7b6307906e58f11eb596d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "55329fd539f4d4e53ff1a864eb92ad57b9a72e22bba6aa65d870c89f7abefd95", + "provenance_path": "tasks/ca0daba3c6a3901074207690/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4ff204b06ecb95509fa7b6307906e58f11eb596d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8ddcf432bf88132f924a69cdef52347f7b03334a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "task_sha256": "a61e96980436cb952a88bb164389f5b7a8dc9c2b30939859a6542fb9b9910be6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..1be40f2f230cd77eda13f3fa7f11dddb355677d5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/instruction.md @@ -0,0 +1,45 @@ +# Schema registry not handling multiple classes with same name correctly + +When registering schemas with the same class name but from different modules, the registry is not properly maintaining them. This causes issues when trying to reference schemas by name. + +## Reproduction + +I have two schemas with the same class name in different modules: + +```python +# module_a.py +from marshmallow import Schema, fields + +class MySchema(Schema): + name = fields.Str() + +# module_b.py +from marshmallow import Schema, fields + +class MySchema(Schema): + age = fields.Int() +``` + +When I try to use a nested field referencing the schema by name, it fails: + +```python +from marshmallow import Schema, fields + +class ParentSchema(Schema): + child = fields.Nested('MySchema') # This fails with RegistryError + +data = ParentSchema().dump({'child': {'name': 'Test'}}) +``` + +I get an error like: +``` +marshmallow.exceptions.RegistryError: Multiple classes with name 'MySchema' were found. Please use the full, module-qualified path. +``` + +Additionally, when registering a schema with the same name in the same module multiple times, it seems to delete the previous registration instead of replacing it. + +This is causing issues with self-referencing schemas as well, where a schema references itself by name. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..a59cc4ebdceb190e147a3e5af58c17bc427136ed --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "8ddcf432bf88132f924a69cdef52347f7b03334a", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "4ff204b06ecb95509fa7b6307906e58f11eb596d" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_decorators.py", + "/testbed/tests/test_deserialization.py", + "/testbed/tests/test_error_store.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_fields.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_registry.py", + "tests/test_schema.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/class_registry.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2325828, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "fb06cc840fdf572c7ad495b5f7b7f881558152295659d8c8a8f0c46516ba4d32", + "is_fork": true, + "learner_path": "tasks/ca0daba3c6a3901074207690/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/4ff204b06ecb95509fa7b6307906e58f11eb596d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "55329fd539f4d4e53ff1a864eb92ad57b9a72e22bba6aa65d870c89f7abefd95", + "provenance_path": "tasks/ca0daba3c6a3901074207690/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4ff204b06ecb95509fa7b6307906e58f11eb596d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8ddcf432bf88132f924a69cdef52347f7b03334a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "task_sha256": "a61e96980436cb952a88bb164389f5b7a8dc9c2b30939859a6542fb9b9910be6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..f44caaef72960d53796f97f0f8f11e3eae9afe28 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "d4ae534dfe959199aedaa30e83ee0f0bbc48d9cd55fa15f6d1c8c75fa05b434c", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/4ff204b06ecb95509fa7b6307906e58f11eb596d/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "efd857d3792246f47bd3513867590fd8426bd42af3a24255935724276324b5b6", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "9fde3ad4aea9ad0817217a8e39f9b530050390eb62a0de5000643428ed9a5732", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "fb06cc840fdf572c7ad495b5f7b7f881558152295659d8c8a8f0c46516ba4d32", + "is_fork": true, + "learner_path": "tasks/ca0daba3c6a3901074207690/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/4ff204b06ecb95509fa7b6307906e58f11eb596d/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "55329fd539f4d4e53ff1a864eb92ad57b9a72e22bba6aa65d870c89f7abefd95", + "provenance_path": "tasks/ca0daba3c6a3901074207690/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4ff204b06ecb95509fa7b6307906e58f11eb596d", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8ddcf432bf88132f924a69cdef52347f7b03334a", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut", + "task_sha256": "a61e96980436cb952a88bb164389f5b7a8dc9c2b30939859a6542fb9b9910be6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..f92a08af7e62204ac50d8d11bbaee2d6793784ab --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/provided-gold.diff @@ -0,0 +1,78 @@ +diff --git a/src/marshmallow/class_registry.py b/src/marshmallow/class_registry.py +index b6b2e3196a99beac9f6b8a0903149f39514c74a4..d41b112e67d49a6b7514dfb4d62a05eb58edc497 100644 +--- a/src/marshmallow/class_registry.py ++++ b/src/marshmallow/class_registry.py +@@ -27,20 +27,45 @@ + + + def register(classname: str, cls: SchemaType) -> None: ++ """Add a class to the registry of serializer classes. When a class is ++ registered, an entry for both its classname and its full, module-qualified ++ path are added to the registry. ++ ++ Example: :: ++ ++ class MyClass: ++ pass ++ ++ ++ register("MyClass", MyClass) ++ # Registry: ++ # { ++ # 'MyClass': [path.to.MyClass], ++ # 'path.to.MyClass': [path.to.MyClass], ++ # } ++ ++ """ ++ # Module where the class is located + module = cls.__module__ ++ # Full module path to the class ++ # e.g. user.schemas.UserSchema + fullpath = ".".join([module, classname]) +- +- if classname in _registry and any( ++ # If the class is already registered; need to check if the entries are ++ # in the same module as cls to avoid having multiple instances of the same ++ # class in the registry ++ if classname in _registry and not any( + each.__module__ == module for each in _registry[classname] + ): +- del _registry[classname] ++ _registry[classname].append(cls) + elif classname not in _registry: + _registry[classname] = [cls] + ++ # Also register the full path + if fullpath not in _registry: ++ _registry.setdefault(fullpath, []).append(cls) ++ else: ++ # If fullpath does exist, replace existing entry + _registry[fullpath] = [cls] +- else: +- _registry[fullpath].append(cls) + return None + + +@@ -52,17 +77,18 @@ + """ + try: + classes = _registry[classname] +- except KeyError: ++ except KeyError as error: + raise RegistryError( + f"Class with name {classname!r} was not found. You may need " + "to import the class." +- ) ++ ) from error + if len(classes) > 1: +- if not all: ++ if all: + return _registry[classname] + raise RegistryError( + f"Multiple classes with name {classname!r} " + "were found. Please use the full, " + "module-qualified path." + ) +- return classes[-1] ++ else: ++ return _registry[classname][0] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e97e5d3bd74fc01a38e2d41dc2e7ffe641242a6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/solution/solve.sh @@ -0,0 +1,84 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/class_registry.py b/src/marshmallow/class_registry.py +index b6b2e3196a99beac9f6b8a0903149f39514c74a4..d41b112e67d49a6b7514dfb4d62a05eb58edc497 100644 +--- a/src/marshmallow/class_registry.py ++++ b/src/marshmallow/class_registry.py +@@ -27,20 +27,45 @@ + + + def register(classname: str, cls: SchemaType) -> None: ++ """Add a class to the registry of serializer classes. When a class is ++ registered, an entry for both its classname and its full, module-qualified ++ path are added to the registry. ++ ++ Example: :: ++ ++ class MyClass: ++ pass ++ ++ ++ register("MyClass", MyClass) ++ # Registry: ++ # { ++ # 'MyClass': [path.to.MyClass], ++ # 'path.to.MyClass': [path.to.MyClass], ++ # } ++ ++ """ ++ # Module where the class is located + module = cls.__module__ ++ # Full module path to the class ++ # e.g. user.schemas.UserSchema + fullpath = ".".join([module, classname]) +- +- if classname in _registry and any( ++ # If the class is already registered; need to check if the entries are ++ # in the same module as cls to avoid having multiple instances of the same ++ # class in the registry ++ if classname in _registry and not any( + each.__module__ == module for each in _registry[classname] + ): +- del _registry[classname] ++ _registry[classname].append(cls) + elif classname not in _registry: + _registry[classname] = [cls] + ++ # Also register the full path + if fullpath not in _registry: ++ _registry.setdefault(fullpath, []).append(cls) ++ else: ++ # If fullpath does exist, replace existing entry + _registry[fullpath] = [cls] +- else: +- _registry[fullpath].append(cls) + return None + + +@@ -52,17 +77,18 @@ + """ + try: + classes = _registry[classname] +- except KeyError: ++ except KeyError as error: + raise RegistryError( + f"Class with name {classname!r} was not found. You may need " + "to import the class." +- ) ++ ) from error + if len(classes) > 1: +- if not all: ++ if all: + return _registry[classname] + raise RegistryError( + f"Multiple classes with name {classname!r} " + "were found. Please use the full, " + "module-qualified path." + ) +- return classes[-1] ++ else: ++ return _registry[classname][0] +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..3df70b30846aa60a7ea6b00e0affa0996dc368b1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:c0627425ff84ba5d391851becf7aada5c48511d1e2d10fed02e748c7286fc9da" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d16601362949064974c15b7ceac7a8b797a47c4f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/test.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted-inventory.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..51602b77e6ffdbf167400a566c00de9bb6e574e6 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted-inventory.json @@ -0,0 +1,102 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 2514, + "mode": 420, + "sha256": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd" + }, + "tests/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "tests/base.py": { + "bytes": 8963, + "mode": 420, + "sha256": "b0ae3b41d3ccf3798641e0519d8cc54b56b395d17e54afcf39a02cc16428e6b3" + }, + "tests/conftest.py": { + "bytes": 566, + "mode": 420, + "sha256": "8a6e204dade8798c79bd6f51b5343c7f439316afe7a9e5225265ddec4d185057" + }, + "tests/foo_serializer.py": { + "bytes": 97, + "mode": 420, + "sha256": "0840f9269e077404f7961dcf6f716676a3b6bc689e63594608c08290fb141c91" + }, + "tests/mypy_test_cases/test_validation_error.py": { + "bytes": 579, + "mode": 420, + "sha256": "cd31a99988128d838f9eb2d596c925d041877cd0b11d2665c678e24754b6e4ab" + }, + "tests/test_decorators.py": { + "bytes": 30937, + "mode": 420, + "sha256": "41b8036cf50c2a33759beb39fea221afa997dee3c379b7a384be05768fbb1bb5" + }, + "tests/test_deserialization.py": { + "bytes": 88128, + "mode": 420, + "sha256": "c35268007c05bf376af5d53b30ceb545bfcbf2fd00594d7dfb92fbbf44873ec2" + }, + "tests/test_error_store.py": { + "bytes": 5137, + "mode": 420, + "sha256": "125ff6ce43dd61f97fc39341de390fde8b845204e561abb9bfa1a14bf3182f8f" + }, + "tests/test_exceptions.py": { + "bytes": 1416, + "mode": 420, + "sha256": "bf954d10a9e9f04b0ee3fcfff18489853fa8f3ccf3f88cc84f35d96655609b77" + }, + "tests/test_fields.py": { + "bytes": 24578, + "mode": 420, + "sha256": "96f280b8d7ccbc5650c2e3a0b20173410b6bffafe716b236b24568365ad082cf" + }, + "tests/test_options.py": { + "bytes": 7852, + "mode": 420, + "sha256": "32e9790fda3daabc64e255b5ca81b43493a55200c781fc966ea8d483a5bb27de" + }, + "tests/test_registry.py": { + "bytes": 6907, + "mode": 420, + "sha256": "9a492812de8af2a55587d4cc6ecb0999c692e5d402a351f5afb4ce61223d507e" + }, + "tests/test_schema.py": { + "bytes": 92822, + "mode": 420, + "sha256": "67efc0bccd973043fedd6877eead645bec809c3ca00ee03c1898b9afc11e7d1f" + }, + "tests/test_serialization.py": { + "bytes": 39066, + "mode": 420, + "sha256": "cbb04513548f1ba827c55bbc2f71c4b197c913b12d6f5c3e615373b63abad95f" + }, + "tests/test_utils.py": { + "bytes": 7716, + "mode": 420, + "sha256": "0b85fa3e8e7fda607d20794827104a16572b198ad43ddde3e3d968518ecfcc59" + }, + "tests/test_validate.py": { + "bytes": 32663, + "mode": 420, + "sha256": "1ec731e95400b20742e6ac0b2e0f2e4e8e389cecd54861dd354ca3020e4378cd" + }, + "tests/test_version_attributes.py": { + "bytes": 336, + "mode": 420, + "sha256": "51dc908d1550acec3e3332ce85927fb2af4d4e684fc273c2348d6ef0a9a9f345" + }, + "tox.ini": { + "bytes": 827, + "mode": 420, + "sha256": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/pyproject.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..d199ea385523c2f3346324bb28a877c73b40b97e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/pyproject.toml @@ -0,0 +1,93 @@ +[project] +name = "marshmallow" +version = "3.23.1" +description = "A lightweight library for converting complex datatypes to and from native Python datatypes." +readme = "README.rst" +license = { file = "LICENSE" } +authors = [{ name = "Steven Loria", email = "sloria1@gmail.com" }] +maintainers = [ + { name = "Steven Loria", email = "sloria1@gmail.com" }, + { name = "Jérôme Lafréchoux", email = "jerome@jolimont.fr" }, + { name = "Jared Deckard", email = "jared@shademaps.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +dependencies = ["packaging>=17.0"] + +[project.urls] +Changelog = "https://marshmallow.readthedocs.io/en/latest/changelog.html" +Funding = "https://opencollective.com/marshmallow" +Issues = "https://github.com/marshmallow-code/marshmallow/issues" +Source = "https://github.com/marshmallow-code/marshmallow" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-marshmallow?utm_source=pypi-marshmallow&utm_medium=pypi" + +[project.optional-dependencies] +docs = [ + "sphinx==8.1.3", + "sphinx-issues==5.0.0", + "alabaster==1.0.0", + "sphinx-version-warning==1.1.2", + "autodocsumm==0.2.14", +] +tests = ["pytest", "simplejson"] +dev = ["marshmallow[tests]", "tox", "pre-commit>=3.5,<5.0"] + +[build-system] +requires = ["flit_core<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.sdist] +include = [ + "docs/", + "tests/", + "CHANGELOG.rst", + "CONTRIBUTING.rst", + "SECURITY.md", + "NOTICE", + "tox.ini", +] +exclude = ["docs/_build/"] + +[tool.ruff] +src = ["src"] +fix = true +show-fixes = true +output-format = "full" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] +ignore = ["E203", "E266", "E501", "E731"] +select = [ + "B", # flake8-bugbear + "E", # pycodestyle error + "F", # pyflakes + "I", # isort + "UP", # pyupgrade + "W", # pycodestyle warning +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["E721"] + +[tool.mypy] +ignore_missing_imports = true +warn_unreachable = true +warn_unused_ignores = true +warn_redundant_casts = true +no_implicit_optional = true + +[tool.pytest.ini_options] +norecursedirs = ".git .ropeproject .tox docs env venv tests/mypy_test_cases" +addopts = "-v --tb=short" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/__init__.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/base.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/base.py new file mode 100644 index 0000000000000000000000000000000000000000..ae1bed0bb14c79d811dd7d01dc179eab2e0b719d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/base.py @@ -0,0 +1,354 @@ +"""Test utilities and fixtures.""" + +import datetime as dt +import functools +import uuid +from enum import Enum, IntEnum +from zoneinfo import ZoneInfo + +import simplejson + +from marshmallow import Schema, fields, missing, post_load, validate +from marshmallow.exceptions import ValidationError + +central = ZoneInfo("America/Chicago") + + +class GenderEnum(IntEnum): + male = 1 + female = 2 + non_binary = 3 + + +class HairColorEnum(Enum): + black = "black hair" + brown = "brown hair" + blond = "blond hair" + red = "red hair" + + +class DateEnum(Enum): + date_1 = dt.date(2004, 2, 29) + date_2 = dt.date(2008, 2, 29) + date_3 = dt.date(2012, 2, 29) + + +ALL_FIELDS = [ + fields.String, + fields.Integer, + fields.Boolean, + fields.Float, + fields.Number, + fields.DateTime, + fields.Time, + fields.Date, + fields.TimeDelta, + fields.Dict, + fields.Url, + fields.Email, + fields.UUID, + fields.Decimal, + fields.IP, + fields.IPv4, + fields.IPv6, + fields.IPInterface, + fields.IPv4Interface, + fields.IPv6Interface, + functools.partial(fields.Enum, GenderEnum), + functools.partial(fields.Enum, HairColorEnum, by_value=fields.String), + functools.partial(fields.Enum, GenderEnum, by_value=fields.Integer), +] + + +##### Custom asserts ##### + + +def assert_date_equal(d1, d2): + assert d1.year == d2.year + assert d1.month == d2.month + assert d1.day == d2.day + + +def assert_time_equal(t1, t2): + assert t1.hour == t2.hour + assert t1.minute == t2.minute + assert t1.second == t2.second + assert t1.microsecond == t2.microsecond + + +##### Models ##### + + +class User: + SPECIES = "Homo sapiens" + + def __init__( + self, + name, + age=0, + id_=None, + homepage=None, + email=None, + registered=True, + time_registered=None, + birthdate=None, + birthtime=None, + balance=100, + sex=GenderEnum.male, + hair_color=HairColorEnum.black, + employer=None, + various_data=None, + ): + self.name = name + self.age = age + # A naive datetime + self.created = dt.datetime(2013, 11, 10, 14, 20, 58) + # A TZ-aware datetime + self.updated = dt.datetime(2013, 11, 10, 14, 20, 58, tzinfo=central) + self.id = id_ + self.homepage = homepage + self.email = email + self.balance = balance + self.registered = registered + self.hair_colors = list(HairColorEnum.__members__) + self.sex_choices = list(GenderEnum.__members__) + self.finger_count = 10 + self.uid = uuid.uuid1() + self.time_registered = time_registered or dt.time(1, 23, 45, 6789) + self.birthdate = birthdate or dt.date(2013, 1, 23) + self.birthtime = birthtime or dt.time(0, 1, 2, 3333) + self.activation_date = dt.date(2013, 12, 11) + self.sex = sex + self.hair_color = hair_color + self.employer = employer + self.relatives = [] + self.various_data = various_data or { + "pets": ["cat", "dog"], + "address": "1600 Pennsylvania Ave\n" "Washington, DC 20006", + } + + @property + def since_created(self): + return dt.datetime(2013, 11, 24) - self.created + + def __repr__(self): + return f"" + + +class Blog: + def __init__(self, title, user, collaborators=None, categories=None, id_=None): + self.title = title + self.user = user + self.collaborators = collaborators or [] # List/tuple of users + self.categories = categories + self.id = id_ + + def __contains__(self, item): + return item.name in [each.name for each in self.collaborators] + + +class DummyModel: + def __init__(self, foo): + self.foo = foo + + def __eq__(self, other): + return self.foo == other.foo + + def __str__(self): + return f"bar {self.foo}" + + +###### Schemas ##### + + +class Uppercased(fields.Field): + """Custom field formatting example.""" + + def _serialize(self, value, attr, obj): + if value: + return value.upper() + + +def get_lowername(obj): + if obj is None: + return missing + if isinstance(obj, dict): + return obj.get("name").lower() + else: + return obj.name.lower() + + +class UserSchema(Schema): + name = fields.String() + age = fields.Float() # type: fields.Field + created = fields.DateTime() + created_formatted = fields.DateTime( + format="%Y-%m-%d", attribute="created", dump_only=True + ) + created_iso = fields.DateTime(format="iso", attribute="created", dump_only=True) + updated = fields.DateTime() + species = fields.String(attribute="SPECIES") + id = fields.String(dump_default="no-id") + uppername = Uppercased(attribute="name", dump_only=True) + homepage = fields.Url() + email = fields.Email() + balance = fields.Decimal() + is_old = fields.Method("get_is_old") # type: fields.Field + lowername = fields.Function(get_lowername) + registered = fields.Boolean() + hair_colors = fields.List(fields.Raw) + sex_choices = fields.List(fields.Raw) + finger_count = fields.Integer() + uid = fields.UUID() + time_registered = fields.Time() + birthdate = fields.Date() + birthtime = fields.Time() + activation_date = fields.Date() + since_created = fields.TimeDelta() + sex = fields.Str(validate=validate.OneOf(list(GenderEnum.__members__))) + various_data = fields.Dict() + + class Meta: + render_module = simplejson + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + @post_load + def make_user(self, data, **kwargs): + return User(**data) + + +class UserMetaSchema(Schema): + """The equivalent of the UserSchema, using the ``fields`` option.""" + + uppername = Uppercased(attribute="name", dump_only=True) + balance = fields.Decimal() + is_old = fields.Method("get_is_old") + lowername = fields.Function(get_lowername) + species = fields.String(attribute="SPECIES") + homepage = fields.Url() + email = fields.Email() + various_data = fields.Dict() + + def get_is_old(self, obj): + if obj is None: + return missing + if isinstance(obj, dict): + age = obj.get("age") + else: + age = obj.age + try: + return age > 80 + except TypeError as te: + raise ValidationError(str(te)) from te + + class Meta: + fields = ( + "name", + "age", + "created", + "updated", + "id", + "homepage", + "uppername", + "email", + "balance", + "is_old", + "lowername", + "species", + "registered", + "hair_colors", + "sex_choices", + "finger_count", + "uid", + "time_registered", + "birthdate", + "birthtime", + "since_created", + "various_data", + ) + + +class UserExcludeSchema(UserSchema): + class Meta: + exclude = ("created", "updated") + + +class UserAdditionalSchema(Schema): + lowername = fields.Function(lambda obj: obj.name.lower()) + + class Meta: + additional = ("name", "age", "created", "email") + + +class UserIntSchema(UserSchema): + age = fields.Integer() + + +class UserFloatStringSchema(UserSchema): + age = fields.Float(as_string=True) + + +class ExtendedUserSchema(UserSchema): + is_old = fields.Boolean() + + +class UserRelativeUrlSchema(UserSchema): + homepage = fields.Url(relative=True) + + +class BlogSchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + categories = fields.List(fields.String) + id = fields.String() + + +class BlogUserMetaSchema(Schema): + user = fields.Nested(UserMetaSchema()) + collaborators = fields.List(fields.Nested(UserMetaSchema())) + + +class BlogSchemaMeta(Schema): + """Same as BlogSerializer but using ``fields`` options.""" + + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema())) + + class Meta: + fields = ("title", "user", "collaborators", "categories", "id") + + +class BlogOnlySchema(Schema): + title = fields.String() + user = fields.Nested(UserSchema) + collaborators = fields.List(fields.Nested(UserSchema(only=("id",)))) + + +class BlogSchemaExclude(BlogSchema): + user = fields.Nested(UserSchema, exclude=("uppername", "species")) + + +class BlogSchemaOnlyExclude(BlogSchema): + user = fields.Nested(UserSchema, only=("name",), exclude=("name", "species")) + + +class mockjson: # noqa + @staticmethod + def dumps(val): + return b"{'foo': 42}" + + @staticmethod + def loads(val): + return {"foo": 42} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/conftest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..fec4c5cc4de97a3f71d1dbdbdae7ef902a9cff9c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/conftest.py @@ -0,0 +1,27 @@ +"""Pytest fixtures that are available in all test modules.""" + +import pytest + +from tests.base import Blog, User, UserSchema + + +@pytest.fixture +def user(): + return User(name="Monty", age=42.3, homepage="http://monty.python.org/") + + +@pytest.fixture +def blog(user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + return Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + + +@pytest.fixture +def serialized_user(user): + return UserSchema().dump(user) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/foo_serializer.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/foo_serializer.py new file mode 100644 index 0000000000000000000000000000000000000000..9a0075b74aff9aca837de50c2d1abc98793450bc --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/foo_serializer.py @@ -0,0 +1,5 @@ +from marshmallow import Schema, fields + + +class FooSerializer(Schema): + _id = fields.Integer() diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/mypy_test_cases/test_validation_error.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/mypy_test_cases/test_validation_error.py new file mode 100644 index 0000000000000000000000000000000000000000..105c7651b723fdd20e19b4249b3bcd71dfdcbf52 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/mypy_test_cases/test_validation_error.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import marshmallow as ma + +# OK types for 'message' +ma.ValidationError("foo") +ma.ValidationError(["foo"]) +ma.ValidationError({"foo": "bar"}) + +# non-OK types for 'message' +ma.ValidationError(0) # type: ignore[arg-type] + +# 'messages' is a dict|list +err = ma.ValidationError("foo") +a: dict | list = err.messages +# union type can't assign to non-union type +b: str = err.messages # type: ignore[assignment] +c: dict = err.messages # type: ignore[assignment] +# 'messages_dict' is a dict, so that it can assign to a dict +d: dict = err.messages_dict diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_decorators.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..a59fb08a1e37b558d1d280857027a58da06e9705 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_decorators.py @@ -0,0 +1,896 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + post_dump, + post_load, + pre_dump, + pre_load, + validates, + validates_schema, +) + + +@pytest.mark.parametrize("partial_val", (True, False)) +def test_decorated_processors(partial_val): + class ExampleSchema(Schema): + """Includes different ways to invoke decorators and set up methods""" + + TAG = "TAG" + + value = fields.Integer(as_string=True) + + # Implicit default raw, pre dump, static method. + @pre_dump + def increment_value(self, item, **kwargs): + assert "many" in kwargs + item["value"] += 1 + return item + + # Implicit default raw, post dump, class method. + @post_dump + def add_tag(self, item, **kwargs): + assert "many" in kwargs + item["value"] = self.TAG + item["value"] + return item + + # Explicitly raw, post dump, instance method. + @post_dump(pass_many=True) + def add_envelope(self, data, many, **kwargs): + key = self.get_envelope_key(many) + return {key: data} + + # Explicitly raw, pre load, instance method. + @pre_load(pass_many=True) + def remove_envelope(self, data, many, partial, **kwargs): + assert partial is partial_val + key = self.get_envelope_key(many) + return data[key] + + @staticmethod + def get_envelope_key(many): + return "data" if many else "datum" + + # Explicitly not raw, pre load, instance method. + @pre_load(pass_many=False) + def remove_tag(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] = item["value"][len(self.TAG) :] + return item + + # Explicit default raw, post load, instance method. + @post_load() + def decrement_value(self, item, partial, **kwargs): + assert partial is partial_val + assert "many" in kwargs + item["value"] -= 1 + return item + + schema = ExampleSchema(partial=partial_val) + + # Need to re-create these because the processors will modify in place. + make_item = lambda: {"value": 3} + make_items = lambda: [make_item(), {"value": 5}] + + item_dumped = schema.dump(make_item()) + assert item_dumped == {"datum": {"value": "TAG4"}} + item_loaded = schema.load(item_dumped) + assert item_loaded == make_item() + + items_dumped = schema.dump(make_items(), many=True) + assert items_dumped == {"data": [{"value": "TAG4"}, {"value": "TAG6"}]} + items_loaded = schema.load(items_dumped, many=True) + assert items_loaded == make_items() + + +#  Regression test for https://github.com/marshmallow-code/marshmallow/issues/347 +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +def test_decorated_processor_returning_none(unknown): + class PostSchema(Schema): + value = fields.Integer() + + @post_load + def load_none(self, item, **kwargs): + return None + + @post_dump + def dump_none(self, item, **kwargs): + return None + + class PreSchema(Schema): + value = fields.Integer() + + @pre_load + def load_none(self, item, **kwargs): + return None + + @pre_dump + def dump_none(self, item, **kwargs): + return None + + schema = PostSchema(unknown=unknown) + assert schema.dump({"value": 3}) is None + assert schema.load({"value": 3}) is None + schema = PreSchema(unknown=unknown) + assert schema.dump({"value": 3}) == {} + with pytest.raises(ValidationError) as excinfo: + schema.load({"value": 3}) + assert excinfo.value.messages == {"_schema": ["Invalid input type."]} + + +class TestPassOriginal: + def test_pass_original_single(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_original=True) + def post_load(self, data, original_data, **kwargs): + ret = data.copy() + ret["_post_load"] = original_data["sentinel"] + return ret + + @post_dump(pass_original=True) + def post_dump(self, data, obj, **kwargs): + ret = data.copy() + ret["_post_dump"] = obj["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum) + assert item_loaded["foo"] == 42 + assert item_loaded["_post_load"] == 24 + + item_dumped = schema.dump(datum) + + assert item_dumped["foo"] == 42 + assert item_dumped["_post_dump"] == 24 + + def test_pass_original_many(self): + class MySchema(Schema): + foo = fields.Field() + + @post_load(pass_many=True, pass_original=True) + def post_load(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_load"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_load"] = original["sentinel"] + return ret + + @post_dump(pass_many=True, pass_original=True) + def post_dump(self, data, original, many, **kwargs): + if many: + ret = [] + for item, orig_item in zip(data, original): + item["_post_dump"] = orig_item["sentinel"] + ret.append(item) + else: + ret = data.copy() + ret["_post_dump"] = original["sentinel"] + return ret + + schema = MySchema(unknown=EXCLUDE) + data = [{"foo": 42, "sentinel": 24}, {"foo": 424, "sentinel": 242}] + items_loaded = schema.load(data, many=True) + assert items_loaded == [ + {"foo": 42, "_post_load": 24}, + {"foo": 424, "_post_load": 242}, + ] + test_values = [e["_post_load"] for e in items_loaded] + assert test_values == [24, 242] + + items_dumped = schema.dump(data, many=True) + assert items_dumped == [ + {"foo": 42, "_post_dump": 24}, + {"foo": 424, "_post_dump": 242}, + ] + + # Also check load/dump of single item + + datum = {"foo": 42, "sentinel": 24} + item_loaded = schema.load(datum, many=False) + assert item_loaded == {"foo": 42, "_post_load": 24} + + item_dumped = schema.dump(datum, many=False) + assert item_dumped == {"foo": 42, "_post_dump": 24} + + +def test_decorated_processor_inheritance(): + class ParentSchema(Schema): + @post_dump + def inherited(self, item, **kwargs): + item["inherited"] = "inherited" + return item + + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "base" + return item + + @post_dump + def deleted(self, item, **kwargs): + item["deleted"] = "retained" + return item + + class ChildSchema(ParentSchema): + @post_dump + def overridden(self, item, **kwargs): + item["overridden"] = "overridden" + return item + + deleted = None + + parent_dumped = ParentSchema().dump({}) + assert parent_dumped == { + "inherited": "inherited", + "overridden": "base", + "deleted": "retained", + } + + child_dumped = ChildSchema().dump({}) + assert child_dumped == {"inherited": "inherited", "overridden": "overridden"} + + +# https://github.com/marshmallow-code/marshmallow/issues/229#issuecomment-138949436 +def test_pre_dump_is_invoked_before_implicit_field_generation(): + class Foo(Schema): + field = fields.Integer() + + @pre_dump + def hook(self, data, **kwargs): + data["generated_field"] = 7 + return data + + class Meta: + # Removing generated_field from here drops it from the output + fields = ("field", "generated_field") + + assert Foo().dump({"field": 5}) == {"field": 5, "generated_field": 7} + + +class ValidatesSchema(Schema): + foo = fields.Int() + + @validates("foo") + def validate_foo(self, value): + if value != 42: + raise ValidationError("The answer to life the universe and everything.") + + +class TestValidatesDecorator: + def test_validates(self): + class VSchema(Schema): + s = fields.String() + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + VSchema().load({"s": "bar"}) + + assert excinfo.value.messages == {"s": ["nope"]} + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/350 + def test_validates_with_attribute(self): + class S1(Schema): + s = fields.String(attribute="string_name") + + @validates("s") + def validate_string(self, data): + raise ValidationError("nope") + + with pytest.raises(ValidationError) as excinfo: + S1().load({"s": "foo"}) + assert excinfo.value.messages == {"s": ["nope"]} + + with pytest.raises(ValidationError): + S1(many=True).load([{"s": "foo"}]) + + def test_validates_decorator(self): + schema = ValidatesSchema() + + errors = schema.validate({"foo": 41}) + assert "foo" in errors + assert errors["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate({"foo": 42}) + assert errors == {} + + errors = schema.validate([{"foo": 42}, {"foo": 43}], many=True) + assert "foo" in errors[1] + assert len(errors[1]["foo"]) == 1 + assert errors[1]["foo"][0] == "The answer to life the universe and everything." + + errors = schema.validate([{"foo": 42}, {"foo": 42}], many=True) + assert errors == {} + + errors = schema.validate({}) + assert errors == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 41}) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert errors + assert result == {} + + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": 42}, {"foo": 43}], many=True) + errors = excinfo.value.messages + result = excinfo.value.valid_data + assert len(result) == 2 + assert result[0] == {"foo": 42} + assert result[1] == {} + assert 1 in errors + assert "foo" in errors[1] + assert errors[1]["foo"] == ["The answer to life the universe and everything."] + + def test_field_not_present(self): + class BadSchema(ValidatesSchema): + @validates("bar") + def validate_bar(self, value): + raise ValidationError("Never raised.") + + schema = BadSchema() + + with pytest.raises(ValueError, match='"bar" field does not exist.'): + schema.validate({"foo": 42}) + + def test_precedence(self): + class Schema2(ValidatesSchema): + foo = fields.Int(validate=lambda n: n != 42) + bar = fields.Int(validate=lambda n: n == 1) + + @validates("bar") + def validate_bar(self, value): + if value != 2: + raise ValidationError("Must be 2") + + schema = Schema2() + + errors = schema.validate({"foo": 42}) + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert "Invalid value." in errors["foo"][0] + + errors = schema.validate({"bar": 3}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert "Invalid value." in errors["bar"][0] + + errors = schema.validate({"bar": 1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "Must be 2" + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/748 + def test_validates_with_data_key(self): + class BadSchema(Schema): + foo = fields.String(data_key="foo-name") + + @validates("foo") + def validate_string(self, data): + raise ValidationError("nope") + + schema = BadSchema() + errors = schema.validate({"foo-name": "data"}) + assert "foo-name" in errors + assert errors["foo-name"] == ["nope"] + + schema = BadSchema() + errors = schema.validate( + [{"foo-name": "data"}, {"foo-name": "data2"}], many=True + ) + assert errors == {0: {"foo-name": ["nope"]}, 1: {"foo-name": ["nope"]}} + + +class TestValidatesSchemaDecorator: + def test_validator_nested_many_invalid_data(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [1]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["Invalid input type."]} + + def test_validator_nested_many_schema_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"_schema": ["This will never work."]} + + def test_validator_nested_many_field_error(self): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema + def validate_schema(self, data, **kwargs): + raise ValidationError("This will never work.", "foo") + + class MySchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = MySchema() + errors = schema.validate({"nested": [{"foo": 1}]}) + assert errors + assert "nested" in errors + assert 0 in errors["nested"] + assert errors["nested"][0] == {"foo": ["This will never work."]} + + @pytest.mark.parametrize("data", ([{"foo": 1, "bar": 2}],)) + @pytest.mark.parametrize( + "pass_many,expected_data,expected_original_data", + ( + [True, [{"foo": 1}], [{"foo": 1, "bar": 2}]], + [False, {"foo": 1}, {"foo": 1, "bar": 2}], + ), + ) + def test_validator_nested_many_pass_original_and_pass_many( + self, pass_many, data, expected_data, expected_original_data + ): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @validates_schema(pass_many=pass_many, pass_original=True) + def validate_schema(self, data, original_data, many, **kwargs): + assert data == expected_data + assert original_data == expected_original_data + assert many is True + raise ValidationError("Method called") + + class MySchema(Schema): + nested = fields.Nested( + NestedSchema, required=True, many=True, unknown=EXCLUDE + ) + + schema = MySchema() + errors = schema.validate({"nested": data}) + error = errors["nested"] if pass_many else errors["nested"][0] + assert error["_schema"][0] == "Method called" + + def test_decorated_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema(pass_many=True) + def validate_raw(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative", "bar") + + schema = MySchema() + errors = schema.validate({"foo": 3}) + assert "_schema" in errors + assert errors["_schema"][0] == "Must be greater than 3" + + errors = schema.validate([{"foo": 4}], many=True) + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "Must provide at least 2 items" + + errors = schema.validate({"foo": 4, "bar": -1}) + assert "bar" in errors + assert len(errors["bar"]) == 1 + assert errors["bar"][0] == "bar must not be negative" + + def test_multiple_validators(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema + def validate_schema(self, data, **kwargs): + if data["foo"] <= 3: + raise ValidationError("Must be greater than 3") + + @validates_schema + def validate_bar(self, data, **kwargs): + if "bar" in data and data["bar"] < 0: + raise ValidationError("bar must not be negative") + + schema = MySchema() + errors = schema.validate({"foo": 3, "bar": -1}) + assert type(errors) is dict + assert "_schema" in errors + assert len(errors["_schema"]) == 2 + assert "Must be greater than 3" in errors["_schema"] + assert "bar must not be negative" in errors["_schema"] + + errors = schema.validate([{"foo": 3, "bar": -1}, {"foo": 3}], many=True) + assert type(errors) is dict + assert "_schema" in errors[0] + assert len(errors[0]["_schema"]) == 2 + assert "Must be greater than 3" in errors[0]["_schema"] + assert "bar must not be negative" in errors[0]["_schema"] + assert len(errors[1]["_schema"]) == 1 + assert "Must be greater than 3" in errors[0]["_schema"] + + def test_multiple_validators_merge_dict_errors(self): + class NestedSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + class MySchema(Schema): + nested = fields.Nested(NestedSchema) + + @validates_schema + def validate_nested_foo(self, data, **kwargs): + raise ValidationError({"nested": {"foo": ["Invalid foo"]}}) + + @validates_schema + def validate_nested_bar_1(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 1"]}}) + + @validates_schema + def validate_nested_bar_2(self, data, **kwargs): + raise ValidationError({"nested": {"bar": ["Invalid bar 2"]}}) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"nested": {"foo": 1, "bar": 2}}) + + assert excinfo.value.messages == { + "nested": { + "foo": ["Invalid foo"], + "bar": ["Invalid bar 1", "Invalid bar 2"], + } + } + + def test_passing_original_data(self): + class MySchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @validates_schema(pass_original=True) + def validate_original(self, data, original_data, partial, **kwargs): + if isinstance(original_data, dict) and isinstance( + original_data["foo"], str + ): + raise ValidationError("foo cannot be a string") + + @validates_schema(pass_many=True, pass_original=True) + def validate_original_bar(self, data, original_data, many, **kwargs): + def check(datum): + if isinstance(datum, dict) and isinstance(datum["bar"], str): + raise ValidationError("bar cannot be a string") + + if many: + for each in original_data: + check(each) + else: + check(original_data) + + schema = MySchema() + + errors = schema.validate({"foo": "4", "bar": 12}) + assert errors["_schema"] == ["foo cannot be a string"] + + errors = schema.validate({"foo": 4, "bar": "42"}) + assert errors["_schema"] == ["bar cannot be a string"] + + errors = schema.validate([{"foo": 4, "bar": "42"}], many=True) + assert errors["_schema"] == ["bar cannot be a string"] + + def test_allow_reporting_field_errors_in_schema_validator(self): + class NestedSchema(Schema): + baz = fields.Int(required=True) + + class MySchema(Schema): + foo = fields.Int(required=True) + bar = fields.Nested(NestedSchema, required=True) + bam = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def consistency_validation(self, data, **kwargs): + errors = {} + if data["bar"]["baz"] != data["foo"]: + errors["bar"] = {"baz": "Non-matching value"} + if data["bam"] > data["foo"]: + errors["bam"] = "Value should be less than foo" + if errors: + raise ValidationError(errors) + + schema = MySchema() + errors = schema.validate({"foo": 2, "bar": {"baz": 5}, "bam": 6}) + assert errors["bar"]["baz"] == "Non-matching value" + assert errors["bam"] == "Value should be less than foo" + + # https://github.com/marshmallow-code/marshmallow/issues/273 + def test_allow_arbitrary_field_names_in_error(self): + class MySchema(Schema): + @validates_schema + def validator(self, data, **kwargs): + raise ValidationError("Error message", "arbitrary_key") + + errors = MySchema().validate({}) + assert errors["arbitrary_key"] == ["Error message"] + + def test_skip_on_field_errors(self): + class MySchema(Schema): + foo = fields.Int(required=True, validate=lambda n: n == 3) + bar = fields.Int(required=True) + + @validates_schema(skip_on_field_errors=True) + def validate_schema(self, data, **kwargs): + if data["foo"] != data["bar"]: + raise ValidationError("Foo and bar must be equal.") + + @validates_schema(skip_on_field_errors=True, pass_many=True) + def validate_many(self, data, many, **kwargs): + if many: + assert type(data) is list + if len(data) < 2: + raise ValidationError("Must provide at least 2 items") + + schema = MySchema() + # check that schema errors still occur with no field errors + errors = schema.validate({"foo": 3, "bar": 4}) + assert "_schema" in errors + assert errors["_schema"][0] == "Foo and bar must be equal." + + errors = schema.validate([{"foo": 3, "bar": 3}], many=True) + assert "_schema" in errors + assert errors["_schema"][0] == "Must provide at least 2 items" + + # check that schema errors don't occur when field errors do + errors = schema.validate({"foo": 3, "bar": "not an int"}) + assert "bar" in errors + assert "_schema" not in errors + + errors = schema.validate({"foo": 2, "bar": 2}) + assert "foo" in errors + assert "_schema" not in errors + + errors = schema.validate([{"foo": 3, "bar": "not an int"}], many=True) + assert "bar" in errors[0] + assert "_schema" not in errors + + +def test_decorator_error_handling(): # noqa: C901 + class ExampleSchema(Schema): + foo = fields.Int() + bar = fields.Int() + + @pre_load() + def pre_load_error1(self, item, **kwargs): + if item["foo"] != 0: + return item + errors = {"foo": ["preloadmsg1"], "bar": ["preloadmsg2", "preloadmsg3"]} + raise ValidationError(errors) + + @pre_load() + def pre_load_error2(self, item, **kwargs): + if item["foo"] != 4: + return item + raise ValidationError("preloadmsg1", "foo") + + @pre_load() + def pre_load_error3(self, item, **kwargs): + if item["foo"] != 8: + return item + raise ValidationError("preloadmsg1") + + @post_load() + def post_load_error1(self, item, **kwargs): + if item["foo"] != 1: + return item + errors = {"foo": ["postloadmsg1"], "bar": ["postloadmsg2", "postloadmsg3"]} + raise ValidationError(errors) + + @post_load() + def post_load_error2(self, item, **kwargs): + if item["foo"] != 5: + return item + raise ValidationError("postloadmsg1", "foo") + + def make_item(foo, bar): + data = schema.load({"foo": foo, "bar": bar}) + assert data is not None + return data + + schema = ExampleSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 0, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "preloadmsg2" in errors["bar"] + assert "preloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 1, "bar": 1}) + errors = excinfo.value.messages + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + assert "bar" in errors + assert len(errors["bar"]) == 2 + assert "postloadmsg2" in errors["bar"] + assert "postloadmsg3" in errors["bar"] + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 4, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "preloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 5, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "foo" in errors + assert len(errors["foo"]) == 1 + assert errors["foo"][0] == "postloadmsg1" + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": 8, "bar": 1}) + errors = excinfo.value.messages + assert len(errors) == 1 + assert "_schema" in errors + assert len(errors["_schema"]) == 1 + assert errors["_schema"][0] == "preloadmsg1" + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"foo": "error"} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_load, post_load]) +def test_decorator_error_handling_with_load_dict_error(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}, "nested_field") + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.load({}) + assert exc.value.messages == {"nested_field": {"foo": "error"}} + schema.dump(object()) + + +@pytest.mark.parametrize("decorator", [pre_dump, post_dump]) +def test_decorator_error_handling_with_dump(decorator): + class ExampleSchema(Schema): + @decorator + def raise_value_error(self, item, **kwargs): + raise ValidationError({"foo": "error"}) + + schema = ExampleSchema() + with pytest.raises(ValidationError) as exc: + schema.dump(object()) + assert exc.value.messages == {"foo": "error"} + schema.load({}) + + +class Nested: + def __init__(self, foo): + self.foo = foo + + +class Example: + def __init__(self, nested): + self.nested = nested + + +example = Example(nested=[Nested(x) for x in range(1)]) + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([example, {"foo": 0}, example.nested[0]],), +) +def test_decorator_post_dump_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_dump(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_dump(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.dump(data) == {"nested": [{"foo": 0}]} + + +@pytest.mark.parametrize( + "data,expected_data,expected_original_data", + ([{"nested": [{"foo": 0}]}, {"foo": 0}, {"foo": 0}],), +) +def test_decorator_post_load_with_nested_original_and_pass_many( + data, expected_data, expected_original_data +): + class NestedSchema(Schema): + foo = fields.Int(required=True) + + @post_load(pass_many=False, pass_original=True) + def check_pass_original_when_pass_many_false( + self, data, original_data, **kwargs + ): + assert data == expected_data + assert original_data == expected_original_data + return data + + @post_load(pass_many=True, pass_original=True) + def check_pass_original_when_pass_many_true( + self, data, original_data, many, **kwargs + ): + assert many is True + assert data == [expected_data] + assert original_data == [expected_original_data] + return data + + class ExampleSchema(Schema): + nested = fields.Nested(NestedSchema, required=True, many=True) + + schema = ExampleSchema() + assert schema.load(data) == data diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_deserialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_deserialization.py new file mode 100644 index 0000000000000000000000000000000000000000..80d44272fdc61d6b1dd7273b27312c119e2129cf --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_deserialization.py @@ -0,0 +1,2298 @@ +import datetime as dt +import decimal +import ipaddress +import math +import uuid +from unittest.mock import patch + +import pytest + +from marshmallow import EXCLUDE, INCLUDE, RAISE, Schema, fields, validate +from marshmallow.exceptions import ValidationError +from marshmallow.validate import Equal +from tests.base import ( + ALL_FIELDS, + DateEnum, + GenderEnum, + HairColorEnum, + assert_date_equal, + assert_time_equal, + central, +) + + +class MockDateTimeOverflowError(dt.datetime): + """Used to simulate the possible OverflowError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OverflowError() + + +class MockDateTimeOSError(dt.datetime): + """Used to simulate the possible OSError of datetime.fromtimestamp""" + + def fromtimestamp(self, *args, **kwargs): + raise OSError() + + +class TestDeserializingNone: + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_allow_none_deserialize_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + assert field.deserialize(None) is None + + # https://github.com/marshmallow-code/marshmallow/issues/111 + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_fields_dont_allow_none_by_default(self, FieldClass): + field = FieldClass() + with pytest.raises(ValidationError, match="Field may not be null."): + field.deserialize(None) + + def test_allow_none_is_true_if_missing_is_true(self): + field = fields.Field(load_default=None) + assert field.allow_none is True + assert field.deserialize(None) is None + + def test_list_field_deserialize_none_to_none(self): + field = fields.List(fields.String(allow_none=True), allow_none=True) + assert field.deserialize(None) is None + + def test_tuple_field_deserialize_none_to_none(self): + field = fields.Tuple([fields.String()], allow_none=True) + assert field.deserialize(None) is None + + def test_list_of_nested_allow_none_deserialize_none_to_none(self): + field = fields.List(fields.Nested(Schema(), allow_none=True)) + assert field.deserialize([None]) == [None] + + def test_list_of_nested_non_allow_none_deserialize_none_to_validation_error(self): + field = fields.List(fields.Nested(Schema(), allow_none=False)) + with pytest.raises(ValidationError): + field.deserialize([None]) + + +class TestFieldDeserialization: + def test_float_field_deserialization(self): + field = fields.Float() + assert math.isclose(field.deserialize("12.3"), 12.3) + assert math.isclose(field.deserialize(12.3), 12.3) + + @pytest.mark.parametrize("in_val", ["bad", "", {}, True, False]) + def test_invalid_float_field_deserialization(self, in_val): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + assert excinfo.value.args[0] == "Not a valid number." + + def test_float_field_overflow(self): + field = fields.Float() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(2**1024) + assert excinfo.value.args[0] == "Number too large." + + def test_integer_field_deserialization(self): + field = fields.Integer() + assert field.deserialize("42") == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42.0") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize("bad") + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError): + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid integer." + + def test_strict_integer_field_deserialization(self): + field = fields.Integer(strict=True) + assert field.deserialize(42) == 42 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42.0) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(decimal.Decimal("42.0")) + assert excinfo.value.args[0] == "Not a valid integer." + with pytest.raises(ValidationError) as excinfo: + field.deserialize("42") + assert excinfo.value.args[0] == "Not a valid integer." + + def test_decimal_field_deserialization(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = 3.14 + m5 = "abc" + m6 = [1, 2] + + field = fields.Decimal() + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + assert isinstance(field.deserialize(m4), decimal.Decimal) + assert field.deserialize(m4).as_tuple() == (0, (3, 1, 4), -2) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m6) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.4") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m4) + assert excinfo.value.args[0] == "Not a valid number." + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m5) + assert excinfo.value.args[0] == "Not a valid number." + + def test_decimal_field_with_places_and_rounding(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.3") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_deserialization_string(self): + m1 = 12 + m2 = "12.355" + m3 = decimal.Decimal(1) + m4 = "abc" + m5 = [1, 2] + + field = fields.Decimal(as_string=True) + assert isinstance(field.deserialize(m1), decimal.Decimal) + assert field.deserialize(m1) == decimal.Decimal(12) + assert isinstance(field.deserialize(m2), decimal.Decimal) + assert field.deserialize(m2) == decimal.Decimal("12.355") + assert isinstance(field.deserialize(m3), decimal.Decimal) + assert field.deserialize(m3) == decimal.Decimal(1) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + + def test_decimal_field_special_values(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1d = field.deserialize(m1) + assert isinstance(m1d, decimal.Decimal) + assert m1d.is_qnan() and not m1d.is_signed() + + m2d = field.deserialize(m2) + assert isinstance(m2d, decimal.Decimal) + assert m2d.is_qnan() and not m2d.is_signed() + + m3d = field.deserialize(m3) + assert isinstance(m3d, decimal.Decimal) + assert m3d.is_qnan() and not m3d.is_signed() + + m4d = field.deserialize(m4) + assert isinstance(m4d, decimal.Decimal) + assert m4d.is_qnan() and not m4d.is_signed() + + m5d = field.deserialize(m5) + assert isinstance(m5d, decimal.Decimal) + assert m5d.is_infinite() and m5d.is_signed() + + m6d = field.deserialize(m6) + assert isinstance(m6d, decimal.Decimal) + assert m6d.is_infinite() and not m6d.is_signed() + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + def test_decimal_field_special_values_not_permitted(self): + m1 = "-NaN" + m2 = "NaN" + m3 = "-sNaN" + m4 = "sNaN" + m5 = "-Infinity" + m6 = "Infinity" + m7 = "-0" + + field = fields.Decimal(places=2) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(m1) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + with pytest.raises(ValidationError): + field.deserialize(m2) + with pytest.raises(ValidationError): + field.deserialize(m3) + with pytest.raises(ValidationError): + field.deserialize(m4) + with pytest.raises(ValidationError): + field.deserialize(m5) + with pytest.raises(ValidationError): + field.deserialize(m6) + + m7d = field.deserialize(m7) + assert isinstance(m7d, decimal.Decimal) + assert m7d.is_zero() and m7d.is_signed() + + @pytest.mark.parametrize("allow_nan", (None, False, True)) + @pytest.mark.parametrize("value", ("nan", "-nan", "inf", "-inf")) + def test_float_field_allow_nan(self, value, allow_nan): + if allow_nan is None: + # Test default case is False + field = fields.Float() + else: + field = fields.Float(allow_nan=allow_nan) + + if allow_nan is True: + res = field.deserialize(value) + assert isinstance(res, float) + if value.endswith("nan"): + assert math.isnan(res) + else: + assert res == float(value) + else: + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert str(excinfo.value.args[0]) == ( + "Special numeric values (nan or infinity) are not permitted." + ) + + def test_string_field_deserialization(self): + field = fields.String() + assert field.deserialize("foo") == "foo" + assert field.deserialize(b"foo") == "foo" + + # https://github.com/marshmallow-code/marshmallow/issues/231 + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + assert excinfo.value.args[0] == "Not a valid string." + + with pytest.raises(ValidationError): + field.deserialize({}) + + def test_boolean_field_deserialization(self): + field = fields.Boolean() + assert field.deserialize(True) is True + assert field.deserialize(False) is False + assert field.deserialize("True") is True + assert field.deserialize("False") is False + assert field.deserialize("true") is True + assert field.deserialize("false") is False + assert field.deserialize("1") is True + assert field.deserialize("0") is False + assert field.deserialize("on") is True + assert field.deserialize("ON") is True + assert field.deserialize("On") is True + assert field.deserialize("off") is False + assert field.deserialize("OFF") is False + assert field.deserialize("Off") is False + assert field.deserialize("y") is True + assert field.deserialize("Y") is True + assert field.deserialize("yes") is True + assert field.deserialize("YES") is True + assert field.deserialize("Yes") is True + assert field.deserialize("n") is False + assert field.deserialize("N") is False + assert field.deserialize("no") is False + assert field.deserialize("NO") is False + assert field.deserialize("No") is False + assert field.deserialize(1) is True + assert field.deserialize(0) is False + + with pytest.raises(ValidationError) as excinfo: + field.deserialize({}) + assert excinfo.value.args[0] == "Not a valid boolean." + + with pytest.raises(ValidationError) as excinfo: + field.deserialize(42) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid-string") + + def test_boolean_field_deserialization_with_custom_truthy_values(self): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + assert field.deserialize("yep") is True + + field = fields.Boolean(truthy=("yep",)) + assert field.deserialize("yep") is True + assert field.deserialize(False) is False + + @pytest.mark.parametrize("in_val", ["notvalid", 123]) + def test_boolean_field_deserialization_with_custom_truthy_values_invalid( + self, in_val + ): + class MyBoolean(fields.Boolean): + truthy = {"yep"} + + field = MyBoolean() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field = fields.Boolean(truthy=("yep",)) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_val) + expected_msg = "Not a valid boolean." + assert str(excinfo.value.args[0]) == expected_msg + + field2 = MyBoolean(error_messages={"invalid": "bad input"}) + with pytest.raises(ValidationError) as excinfo: + field2.deserialize(in_val) + assert str(excinfo.value.args[0]) == "bad input" + + field2 = fields.Boolean( + truthy=("yep",), error_messages={"invalid": "bad input"} + ) + + def test_boolean_field_deserialization_with_empty_truthy(self): + field = fields.Boolean(truthy=()) + assert field.deserialize("yep") is True + assert field.deserialize(True) is True + assert field.deserialize(False) is False + + def test_boolean_field_deserialization_with_custom_falsy_values(self): + field = fields.Boolean(falsy=("nope",)) + assert field.deserialize("nope") is False + assert field.deserialize(True) is True + + def test_field_toggle_show_invalid_value_in_error_message(self): + error_messages = {"invalid": "Not valid: {input}"} + boolfield = fields.Boolean(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + boolfield.deserialize("notabool") + assert str(excinfo.value.args[0]) == "Not valid: notabool" + + numfield = fields.Number(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + numfield.deserialize("notanum") + assert str(excinfo.value.args[0]) == "Not valid: notanum" + + intfield = fields.Integer(error_messages=error_messages) + with pytest.raises(ValidationError) as excinfo: + intfield.deserialize("notanint") + assert str(excinfo.value.args[0]) == "Not valid: notanint" + + date_error_messages = {"invalid": "Not a valid {obj_type}: {input}"} + datefield = fields.DateTime(error_messages=date_error_messages) + with pytest.raises(ValidationError) as excinfo: + datefield.deserialize("notadate") + assert str(excinfo.value.args[0]) == "Not a valid datetime: notadate" + + @pytest.mark.parametrize( + "in_value", + [ + "not-a-datetime", + 42, + True, + False, + 0, + "", + [], + "2018", + "2018-01-01", + dt.datetime.now().strftime("%H:%M:%S %Y-%m-%d"), + dt.datetime.now().strftime("%m-%d-%Y %H:%M:%S"), + ], + ) + def test_invalid_datetime_deserialization(self, in_value): + field = fields.DateTime() + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + def test_custom_date_format_datetime_field_deserialization(self): + # Datetime string with format "%H:%M:%S.%f %Y-%m-%d" + datestring = "10:11:12.123456 2019-01-02" + + # Deserialization should fail when datestring is not of same format + field = fields.DateTime(format="%d-%m-%Y %H:%M:%S") + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(datestring) + + field = fields.DateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.NaiveDateTime(format="%H:%M:%S.%f %Y-%m-%d") + assert field.deserialize(datestring) == dt.datetime( + 2019, 1, 2, 10, 11, 12, 123456 + ) + + field = fields.AwareDateTime(format="%H:%M:%S.%f %Y-%m-%d") + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(datestring) + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ( + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + False, + ), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_rfc_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601"]) + @pytest.mark.parametrize( + ("value", "expected", "aware"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45), False), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + True, + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + True, + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + True, + ), + ], + ) + def test_iso_datetime_field_deserialization(self, fmt, value, expected, aware): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + field = fields.NaiveDateTime(format=fmt) + if aware: + with pytest.raises(ValidationError, match="Not a valid naive datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + field = fields.AwareDateTime(format=fmt) + if not aware: + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + else: + assert field.deserialize(value) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", "1384043025", dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp", 1384043025.12, dt.datetime(2013, 11, 10, 0, 23, 45, 120000)), + ( + "timestamp", + 1384043025.123456, + dt.datetime(2013, 11, 10, 0, 23, 45, 123456), + ), + ("timestamp", 1, dt.datetime(1970, 1, 1, 0, 0, 1)), + ("timestamp_ms", 1384043025000, dt.datetime(2013, 11, 10, 0, 23, 45)), + ("timestamp_ms", 1000, dt.datetime(1970, 1, 1, 0, 0, 1)), + ], + ) + def test_timestamp_field_deserialization(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.deserialize(value) == expected + + # By default, a datetime from a timestamp is never aware. + field = fields.NaiveDateTime(format=fmt) + assert field.deserialize(value) == expected + + field = fields.AwareDateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid aware datetime."): + field.deserialize(value) + + # But it can be added by providing a default. + field = fields.AwareDateTime(format=fmt, default_timezone=central) + expected_aware = expected.replace(tzinfo=central) + assert field.deserialize(value) == expected_aware + + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "in_value", + ["", "!@#", -1, dt.datetime(2013, 11, 10, 1, 23, 45)], + ) + def test_invalid_timestamp_field_deserialization(self, fmt, in_value): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(in_value) + + #  Regression test for https://github.com/marshmallow-code/marshmallow/pull/2102 + @pytest.mark.parametrize("fmt", ["timestamp", "timestamp_ms"]) + @pytest.mark.parametrize( + "mock_fromtimestamp", [MockDateTimeOSError, MockDateTimeOverflowError] + ) + def test_oversized_timestamp_field_deserialization(self, fmt, mock_fromtimestamp): + with patch("datetime.datetime", mock_fromtimestamp): + field = fields.DateTime(format=fmt) + with pytest.raises(ValidationError, match="Not a valid datetime."): + field.deserialize(99999999999999999) + + @pytest.mark.parametrize( + ("fmt", "timezone", "value", "expected"), + [ + ("iso", None, "2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "iso", + dt.timezone.utc, + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "iso", + central, + "2013-11-10T01:23:45-03:00", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ( + "rfc", + None, + "Sun, 10 Nov 2013 01:23:45 -0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + dt.timezone.utc, + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45), + ), + ( + "rfc", + central, + "Sun, 10 Nov 2013 01:23:45 -0300", + dt.datetime(2013, 11, 9, 22, 23, 45), + ), + ], + ) + def test_naive_datetime_with_timezone(self, fmt, timezone, value, expected): + field = fields.NaiveDateTime(format=fmt, timezone=timezone) + assert field.deserialize(value) == expected + + @pytest.mark.parametrize("timezone", (dt.timezone.utc, central)) + @pytest.mark.parametrize( + ("fmt", "value"), + [("iso", "2013-11-10T01:23:45"), ("rfc", "Sun, 10 Nov 2013 01:23:45")], + ) + def test_aware_datetime_default_timezone(self, fmt, timezone, value): + field = fields.AwareDateTime(format=fmt, default_timezone=timezone) + assert field.deserialize(value) == dt.datetime( + 2013, 11, 10, 1, 23, 45, tzinfo=timezone + ) + + def test_time_field_deserialization(self): + field = fields.Time() + t = dt.time(1, 23, 45) + t_formatted = t.isoformat() + result = field.deserialize(t_formatted) + assert isinstance(result, dt.time) + assert_time_equal(result, t) + # With microseconds + t2 = dt.time(1, 23, 45, 6789) + t2_formatted = t2.isoformat() + result2 = field.deserialize(t2_formatted) + assert_time_equal(result2, t2) + + @pytest.mark.parametrize("in_data", ["badvalue", "", [], 42]) + def test_invalid_time_field_deserialization(self, in_data): + field = fields.Time() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_data) + assert excinfo.value.args[0] == "Not a valid time." + + def test_custom_time_format_time_field_deserialization(self): + # Time string with format "%f.%S:%M:%H" + timestring = "123456.12:11:10" + + # Deserialization should fail when timestring is not of same format + field = fields.Time(format="%S:%M:%H") + with pytest.raises(ValidationError, match="Not a valid time."): + field.deserialize(timestring) + + field = fields.Time(format="%f.%S:%M:%H") + assert field.deserialize(timestring) == dt.time(10, 11, 12, 123456) + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + ("01:23:45", dt.time(1, 23, 45)), + ("01:23:45+01:00", dt.time(1, 23, 45)), + ("01:23:45.123", dt.time(1, 23, 45, 123000)), + ("01:23:45.123456", dt.time(1, 23, 45, 123456)), + ], + ) + def test_iso_time_field_deserialization(self, fmt, value, expected): + if fmt is None: + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.deserialize(value) == expected + + def test_invalid_timedelta_precision(self): + with pytest.raises(ValueError, match='The precision must be "days",'): + fields.TimeDelta("invalid") + + def test_timedelta_field_deserialization(self): + field = fields.TimeDelta() + result = field.deserialize("42") + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 42 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + result = field.deserialize(100000) + assert result.days == 1 + assert result.seconds == 13600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + result = field.deserialize("-42") + assert isinstance(result, dt.timedelta) + assert result.days == -42 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 1 + assert result.microseconds == 1 + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + result = field.deserialize(86400 * 10**6 + 1) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 0 + assert result.microseconds == 1 + + field = fields.TimeDelta() + result = field.deserialize(12.9) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 12 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + result = field.deserialize(1) + assert isinstance(result, dt.timedelta) + assert result.days == 7 + assert result.seconds == 0 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.HOURS) + result = field.deserialize(25) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 3600 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + result = field.deserialize(1441) + assert isinstance(result, dt.timedelta) + assert result.days == 1 + assert result.seconds == 60 + assert result.microseconds == 0 + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + result = field.deserialize(123456) + assert isinstance(result, dt.timedelta) + assert result.days == 0 + assert result.seconds == 123 + assert result.microseconds == 456000 + + total_microseconds_value = 322.0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_microseconds_value + ) + + total_microseconds_value = 322.12345 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + result = field.deserialize(total_microseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, math.floor(total_microseconds_value) + ) + + total_milliseconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + result = field.deserialize(total_milliseconds_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + result.total_seconds() / unit_value, total_milliseconds_value + ) + + total_seconds_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + result = field.deserialize(total_seconds_value) + assert isinstance(result, dt.timedelta) + assert math.isclose(result.total_seconds(), total_seconds_value) + + total_minutes_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + result = field.deserialize(total_minutes_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_minutes_value) + + total_hours_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + result = field.deserialize(total_hours_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_hours_value) + + total_days_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + result = field.deserialize(total_days_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_days_value) + + total_weeks_value = 322.223 + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + result = field.deserialize(total_weeks_value) + assert isinstance(result, dt.timedelta) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose(result.total_seconds() / unit_value, total_weeks_value) + + @pytest.mark.parametrize("in_value", ["", "badvalue", [], 9999999999]) + def test_invalid_timedelta_field_deserialization(self, in_value): + field = fields.TimeDelta(fields.TimeDelta.DAYS) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + assert excinfo.value.args[0] == "Not a valid period of time." + + @pytest.mark.parametrize("format", (None, "%Y-%m-%d")) + def test_date_field_deserialization(self, format): + field = fields.Date(format=format) + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = field.deserialize(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + @pytest.mark.parametrize( + "in_value", ["", 123, [], dt.date(2014, 8, 21).strftime("%d-%m-%Y")] + ) + def test_invalid_date_field_deserialization(self, in_value): + field = fields.Date() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + msg = "Not a valid date." + assert excinfo.value.args[0] == msg + + def test_dict_field_deserialization(self): + data = {"foo": "bar"} + field = fields.Dict() + load = field.deserialize(data) + assert load == {"foo": "bar"} + # Check load is a distinct object + load["foo"] = "baz" + assert data["foo"] == "bar" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("baddict") + assert excinfo.value.args[0] == "Not a valid mapping type." + + def test_structured_dict_value_deserialization(self): + field = fields.Dict(values=fields.List(fields.Str)) + assert field.deserialize({"foo": ["bar", "baz"]}) == {"foo": ["bar", "baz"]} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": [1, 2], "bar": "baz", "ham": ["spam"]}) + assert excinfo.value.args[0] == { + "foo": {"value": {0: ["Not a valid string."], 1: ["Not a valid string."]}}, + "bar": {"value": ["Not a valid list."]}, + } + assert excinfo.value.valid_data == {"foo": [], "ham": ["spam"]} + + def test_structured_dict_key_deserialization(self): + field = fields.Dict(keys=fields.Str) + assert field.deserialize({"foo": "bar"}) == {"foo": "bar"} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar", "foo": "baz"}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {"foo": "baz"} + + def test_structured_dict_key_value_deserialization(self): + field = fields.Dict( + keys=fields.Str( + validate=[validate.Email(), validate.Regexp(r".*@test\.com$")] + ), + values=fields.Decimal, + ) + assert field.deserialize({"foo@test.com": 1}) == { + "foo@test.com": decimal.Decimal(1) + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: "bar"}) + assert excinfo.value.args[0] == { + 1: {"key": ["Not a valid string."], "value": ["Not a valid number."]} + } + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo@test.com": "bar"}) + assert excinfo.value.args[0] == { + "foo@test.com": {"value": ["Not a valid number."]} + } + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({1: 1}) + assert excinfo.value.args[0] == {1: {"key": ["Not a valid string."]}} + assert excinfo.value.valid_data == {} + with pytest.raises(ValidationError) as excinfo: + field.deserialize({"foo": "bar"}) + assert excinfo.value.args[0] == { + "foo": { + "key": [ + "Not a valid email address.", + "String does not match expected pattern.", + ], + "value": ["Not a valid number."], + } + } + assert excinfo.value.valid_data == {} + + def test_url_field_deserialization(self): + field = fields.Url() + assert field.deserialize("https://duckduckgo.com") == "https://duckduckgo.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("badurl") + assert excinfo.value.args[0][0] == "Not a valid URL." + # Relative URLS not allowed by default + with pytest.raises(ValidationError) as excinfo: + field.deserialize("/foo/bar") + assert excinfo.value.args[0][0] == "Not a valid URL." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_url_field_non_list_validators(self): + field = fields.Url(validate=(validate.Length(min=16),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("https://abc.def") + + def test_relative_url_field_deserialization(self): + field = fields.Url(relative=True) + assert field.deserialize("/foo/bar") == "/foo/bar" + + def test_url_field_schemes_argument(self): + field = fields.URL() + url = "ws://test.test" + with pytest.raises(ValidationError): + field.deserialize(url) + field2 = fields.URL(schemes={"http", "https", "ws"}) + assert field2.deserialize(url) == url + + def test_email_field_deserialization(self): + field = fields.Email() + assert field.deserialize("foo@bar.com") == "foo@bar.com" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalidemail") + assert excinfo.value.args[0][0] == "Not a valid email address." + + field = fields.Email(validate=[validate.Length(min=12)]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("foo@bar.com") + assert excinfo.value.args[0][0] == "Shorter than minimum length 12." + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/1400 + def test_email_field_non_list_validators(self): + field = fields.Email(validate=(validate.Length(min=9),)) + with pytest.raises(ValidationError, match="Shorter than minimum length"): + field.deserialize("a@bc.com") + + def test_function_field_deserialization_is_noop_by_default(self): + field = fields.Function(lambda x: None) + # Default is noop + assert field.deserialize("foo") == "foo" + assert field.deserialize(42) == 42 + + def test_function_field_deserialization_with_callable(self): + field = fields.Function(lambda x: None, deserialize=lambda val: val.upper()) + assert field.deserialize("foo") == "FOO" + + def test_function_field_deserialization_with_context(self): + class Parent(Schema): + pass + + field = fields.Function( + lambda x: None, + deserialize=lambda val, context: val.upper() + context["key"], + ) + field.parent = Parent(context={"key": "BAR"}) + assert field.deserialize("foo") == "FOOBAR" + + def test_function_field_passed_deserialize_only_is_load_only(self): + field = fields.Function(deserialize=lambda val: val.upper()) + assert field.load_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_load_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.load_only is False + + def test_uuid_field_deserialization(self): + field = fields.UUID() + uuid_str = str(uuid.uuid4()) + result = field.deserialize(uuid_str) + assert isinstance(result, uuid.UUID) + assert str(result) == uuid_str + + uuid4 = uuid.uuid4() + result = field.deserialize(uuid4) + assert isinstance(result, uuid.UUID) + assert result == uuid4 + + uuid_bytes = b"]\xc7wW\x132O\xf9\xa5\xbe\x13\x1f\x02\x18\xda\xbf" + result = field.deserialize(uuid_bytes) + assert isinstance(result, uuid.UUID) + assert result.bytes == uuid_bytes + + @pytest.mark.parametrize("in_value", ["malformed", 123, [], b"tooshort"]) + def test_invalid_uuid_deserialization(self, in_value): + field = fields.UUID() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid UUID." + + def test_ip_field_deserialization(self): + field = fields.IP() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + @pytest.mark.parametrize( + "in_value", + ["malformed", 123, b"\x01\x02\03", "192.168", "192.168.0.1/24", "ff::aa:1::2"], + ) + def test_invalid_ip_deserialization(self, in_value): + field = fields.IP() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP address." + + def test_ipv4_field_deserialization(self): + field = fields.IPv4() + ipv4_str = "140.82.118.3" + result = field.deserialize(ipv4_str) + assert isinstance(result, ipaddress.IPv4Address) + assert str(result) == ipv4_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/24", + "2a00:1450:4001:81d::200e", + ], + ) + def test_invalid_ipv4_deserialization(self, in_value): + field = fields.IPv4() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 address." + + def test_ipv6_field_deserialization(self): + field = fields.IPv6() + ipv6_str = "2a00:1450:4001:824::200e" + result = field.deserialize(ipv6_str) + assert isinstance(result, ipaddress.IPv6Address) + assert str(result) == ipv6_str + + def test_ipinterface_field_deserialization(self): + field = fields.IPInterface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "ff::aa:1::2", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipinterface_deserialization(self, in_value): + field = fields.IPInterface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IP interface." + + def test_ipv4interface_field_deserialization(self): + field = fields.IPv4Interface() + ipv4interface_str = "140.82.118.3/24" + result = field.deserialize(ipv4interface_str) + assert isinstance(result, ipaddress.IPv4Interface) + assert str(result) == ipv4interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "192.168", + "192.168.0.1/33", + "2a00:1450:4001:81d::200e", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv4interface_deserialization(self, in_value): + field = fields.IPv4Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv4 interface." + + def test_ipv6interface_field_deserialization(self): + field = fields.IPv6Interface() + ipv6interface_str = "2a00:1450:4001:824::200e/128" + result = field.deserialize(ipv6interface_str) + assert isinstance(result, ipaddress.IPv6Interface) + assert str(result) == ipv6interface_str + + @pytest.mark.parametrize( + "in_value", + [ + "malformed", + 123, + b"\x01\x02\03", + "ff::aa:1::2", + "192.168.0.1", + "192.168.0.1/24", + "2a00:1450:4001:824::200e/129", + ], + ) + def test_invalid_ipv6interface_deserialization(self, in_value): + field = fields.IPv6Interface() + with pytest.raises(ValidationError) as excinfo: + field.deserialize(in_value) + + assert excinfo.value.args[0] == "Not a valid IPv6 interface." + + def test_enum_field_by_symbol_deserialization(self): + field = fields.Enum(GenderEnum) + assert field.deserialize("male") == GenderEnum.male + + def test_enum_field_by_symbol_invalid_value(self): + field = fields.Enum(GenderEnum) + with pytest.raises( + ValidationError, match="Must be one of: male, female, non_binary." + ): + field.deserialize("dummy") + + def test_enum_field_by_symbol_not_string(self): + field = fields.Enum(GenderEnum) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + + def test_enum_field_by_value_true_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=True) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=True) + assert field.deserialize(1) == GenderEnum.male + + def test_enum_field_by_value_field_deserialization(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.deserialize("black hair") == HairColorEnum.black + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.deserialize(1) == GenderEnum.male + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.deserialize("29/02/2004") == DateEnum.date_1 + + def test_enum_field_by_value_true_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_invalid_value(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises( + ValidationError, match="Must be one of: 29/02/2004, 29/02/2008, 29/02/2012." + ): + field.deserialize("28/02/2004") + + def test_enum_field_by_value_true_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=True) + with pytest.raises( + ValidationError, + match="Must be one of: black hair, brown hair, blond hair, red hair.", + ): + field.deserialize("dummy") + field = fields.Enum(GenderEnum, by_value=True) + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + field.deserialize(12) + + def test_enum_field_by_value_field_wrong_type(self): + field = fields.Enum(HairColorEnum, by_value=fields.String) + with pytest.raises(ValidationError, match="Not a valid string."): + field.deserialize(12) + field = fields.Enum(GenderEnum, by_value=fields.Integer) + with pytest.raises(ValidationError, match="Not a valid integer."): + field.deserialize("dummy") + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + with pytest.raises(ValidationError, match="Not a valid date."): + field.deserialize("30/02/2004") + + def test_deserialization_function_must_be_callable(self): + with pytest.raises(TypeError): + fields.Function(lambda x: None, deserialize="notvalid") + + def test_method_field_deserialization_is_noop_by_default(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name") + + def uppercase_name(self, obj): + return obj.upper() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("steve") == "steve" + + def test_deserialization_method(self): + class MiniUserSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + def uppercase_name(self, obj): + return obj.name.upper() + + def lowercase_name(self, value): + return value.lower() + + s = MiniUserSchema() + assert s.fields["uppername"].deserialize("STEVE") == "steve" + + def test_deserialization_method_must_be_a_method(self): + class BadSchema(Schema): + uppername = fields.Method("uppercase_name", deserialize="lowercase_name") + + with pytest.raises(AttributeError): + BadSchema() + + def test_method_field_deserialize_only(self): + class MethodDeserializeOnly(Schema): + name = fields.Method(deserialize="lowercase_name") + + def lowercase_name(self, value): + return value.lower() + + assert MethodDeserializeOnly().load({"name": "ALEC"})["name"] == "alec" + + def test_datetime_list_field_deserialization(self): + dtimes = dt.datetime.now(), dt.datetime.now(), dt.datetime.now(dt.timezone.utc) + dstrings = [each.isoformat() for each in dtimes] + field = fields.List(fields.DateTime()) + result = field.deserialize(dstrings) + assert all(isinstance(each, dt.datetime) for each in result) + for actual, expected in zip(result, dtimes): + assert_date_equal(actual, expected) + + def test_list_field_deserialize_invalid_item(self): + field = fields.List(fields.DateTime) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", 42]) + assert excinfo.value.args[0] == {1: ["Not a valid string."]} + + def test_list_field_deserialize_multiple_invalid_items(self): + field = fields.List( + fields.Int( + validate=validate.Range(10, 20, error="Value {input} not in range") + ) + ) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_list_field_deserialize_value_that_is_not_a_list(self, value): + field = fields.List(fields.Str()) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid list." + + def test_datetime_int_tuple_field_deserialization(self): + dtime = dt.datetime.now() + data = dtime.isoformat(), 42 + field = fields.Tuple([fields.DateTime(), fields.Integer()]) + result = field.deserialize(data) + + assert isinstance(result, tuple) + assert len(result) == 2 + for val, type_, true_val in zip(result, (dt.datetime, int), (dtime, 42)): + assert isinstance(val, type_) + assert val == true_val + + def test_tuple_field_deserialize_invalid_item(self): + field = fields.Tuple([fields.DateTime]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["badvalue"]) + assert excinfo.value.args[0] == {0: ["Not a valid datetime."]} + + field = fields.Tuple([fields.Str(), fields.Integer()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(["good", "bad"]) + assert excinfo.value.args[0] == {1: ["Not a valid integer."]} + + def test_tuple_field_deserialize_multiple_invalid_items(self): + validator = validate.Range(10, 20, error="Value {input} not in range") + field = fields.Tuple( + [ + fields.Int(validate=validator), + fields.Int(validate=validator), + fields.Int(validate=validator), + ] + ) + + with pytest.raises(ValidationError) as excinfo: + field.deserialize([10, 5, 25]) + assert len(excinfo.value.args[0]) == 2 + assert excinfo.value.args[0][1] == ["Value 5 not in range"] + assert excinfo.value.args[0][2] == ["Value 25 not in range"] + + @pytest.mark.parametrize("value", ["notalist", 42, {}]) + def test_tuple_field_deserialize_value_that_is_not_a_collection(self, value): + field = fields.Tuple([fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize(value) + assert excinfo.value.args[0] == "Not a valid tuple." + + def test_tuple_field_deserialize_invalid_length(self): + field = fields.Tuple([fields.Str(), fields.Str()]) + with pytest.raises(ValidationError) as excinfo: + field.deserialize([42]) + assert excinfo.value.args[0] == "Length must be 2." + + def test_constant_field_deserialization(self): + field = fields.Constant("something") + assert field.deserialize("whatever") == "something" + + def test_constant_is_always_included_in_deserialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.load({})["foo"] == 42 + assert sch.load({"foo": 24})["foo"] == 42 + + def test_field_deserialization_with_user_validator_function(self): + field = fields.String(validate=lambda s: s.lower() == "valid") + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError) as excinfo: + field.deserialize("invalid") + assert excinfo.value.args[0][0] == "Invalid value." + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validator_class_that_returns_bool(self): + class MyValidator: + def __call__(self, val): + if val == "valid": + return True + return False + + field = fields.Field(validate=MyValidator()) + assert field.deserialize("valid") == "valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_user_validator_that_raises_error_with_list( + self, + ): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + errors = MySchema().validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + def test_validator_must_return_false_to_raise_error(self): + # validator returns None, so anything validates + field = fields.String(validate=lambda s: None) + assert field.deserialize("Valid") == "Valid" + # validator returns False, so nothing validates + field2 = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError): + field2.deserialize("invalid") + + def test_field_deserialization_with_validator_with_nonascii_input(self): + field = fields.String(validate=lambda s: False) + with pytest.raises(ValidationError) as excinfo: + field.deserialize("привет") + assert type(excinfo.value) is ValidationError + + def test_field_deserialization_with_user_validators(self): + validators_gen = ( + func + for func in ( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ) + + m_colletion_type = [ + fields.String( + validate=[ + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ] + ), + fields.String( + validate=( + lambda s: s.lower() == "valid", + lambda s: s.lower()[::-1] == "dilav", + ) + ), + fields.String(validate=validators_gen), + ] + + for field in m_colletion_type: + assert field.deserialize("Valid") == "Valid" + with pytest.raises(ValidationError, match="Invalid value."): + field.deserialize("invalid") + + def test_field_deserialization_with_custom_error_message(self): + field = fields.String( + validate=lambda s: s.lower() == "valid", + error_messages={"validator_failed": "Bad value."}, + ) + with pytest.raises(ValidationError, match="Bad value."): + field.deserialize("invalid") + + +# No custom deserialization behavior, so a dict is returned +class SimpleUserSchema(Schema): + name = fields.String() + age = fields.Float() + + +class Validator(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=lambda n: n > 0) + + +class Validators(Schema): + email = fields.Email() + colors = fields.Str(validate=validate.OneOf(["red", "blue"])) + age = fields.Integer(validate=[lambda n: n > 0, lambda n: n < 100]) + + +class TestSchemaDeserialization: + def test_deserialize_to_dict(self): + user_dict = {"name": "Monty", "age": "42.3"} + result = SimpleUserSchema().load(user_dict) + assert result["name"] == "Monty" + assert math.isclose(result["age"], 42.3) + + def test_deserialize_with_missing_values(self): + user_dict = {"name": "Monty"} + result = SimpleUserSchema().load(user_dict) + # 'age' is not included in result + assert result == {"name": "Monty"} + + def test_deserialize_many(self): + users_data = [{"name": "Mick", "age": "914"}, {"name": "Keith", "age": "8442"}] + result = SimpleUserSchema(many=True).load(users_data) + assert isinstance(result, list) + user = result[0] + assert user["age"] == int(users_data[0]["age"]) + + def test_exclude(self): + schema = SimpleUserSchema(exclude=("age",), unknown=EXCLUDE) + result = schema.load({"name": "Monty", "age": 42}) + assert "name" in result + assert "age" not in result + + def test_nested_single_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, unknown=EXCLUDE) + + blog_dict = { + "title": "Gimme Shelter", + "author": {"name": "Mick", "age": "914", "email": "mick@stones.com"}, + } + result = SimpleBlogSerializer().load(blog_dict) + author = result["author"] + assert author["name"] == "Mick" + assert author["age"] == 914 + assert "email" not in author + + def test_nested_list_deserialization_to_dict(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + authors = fields.Nested(SimpleUserSchema, many=True) + + blog_dict = { + "title": "Gimme Shelter", + "authors": [ + {"name": "Mick", "age": "914"}, + {"name": "Keith", "age": "8442"}, + ], + } + result = SimpleBlogSerializer().load(blog_dict) + assert isinstance(result["authors"], list) + author = result["authors"][0] + assert author["name"] == "Mick" + assert author["age"] == 914 + + def test_nested_single_none_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), allow_none=False) + + sch = OwnerSchema() + errors = sch.validate({"pet": None}) + assert "pet" in errors + assert errors["pet"] == ["Field may not be null."] + + def test_nested_many_non_not_allowed(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, allow_none=False, many=True) + + sch = StoreSchema() + errors = sch.validate({"pets": None}) + assert "pets" in errors + assert errors["pets"] == ["Field may not be null."] + + def test_nested_single_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class OwnerSchema(Schema): + pet = fields.Nested(PetSchema(), required=True) + + sch = OwnerSchema() + errors = sch.validate({}) + assert "pet" in errors + assert errors["pet"] == ["Missing data for required field."] + + def test_nested_many_required_missing(self): + class PetSchema(Schema): + name = fields.Str() + + class StoreSchema(Schema): + pets = fields.Nested(PetSchema, required=True, many=True) + + sch = StoreSchema() + errors = sch.validate({}) + assert "pets" in errors + assert errors["pets"] == ["Missing data for required field."] + + def test_nested_only_basestring(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + child = fields.Pluck(ANestedSchema, "pk") + + sch = MainSchema() + result = sch.load({"pk": "123", "child": "456"}) + assert result["child"]["pk"] == "456" + + def test_nested_only_basestring_with_list_data(self): + class ANestedSchema(Schema): + pk = fields.Str() + + class MainSchema(Schema): + pk = fields.Str() + children = fields.Pluck(ANestedSchema, "pk", many=True) + + sch = MainSchema() + result = sch.load({"pk": "123", "children": ["456", "789"]}) + assert result["children"][0]["pk"] == "456" + assert result["children"][1]["pk"] == "789" + + def test_nested_none_deserialization(self): + class SimpleBlogSerializer(Schema): + title = fields.String() + author = fields.Nested(SimpleUserSchema, allow_none=True) + + blog_dict = {"title": "Gimme Shelter", "author": None} + result = SimpleBlogSerializer().load(blog_dict) + assert result["author"] is None + assert result["title"] == blog_dict["title"] + + def test_deserialize_with_attribute_param(self): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer().load(data) + assert result["email"] == "foo@bar.com" + assert result["age"] == 42 + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/450 + def test_deserialize_with_attribute_param_symmetry(self): + class MySchema(Schema): + foo = fields.Field(attribute="bar.baz") + + schema = MySchema() + dump_data = schema.dump({"bar": {"baz": 42}}) + assert dump_data == {"foo": 42} + + load_data = schema.load({"foo": 42}) + assert load_data == {"bar": {"baz": 42}} + + def test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + username = fields.Email(attribute="email") + years = fields.Integer(attribute="age") + + data = {"username": "foobar.com", "years": "42"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["username"] == ["Not a valid email address."] + + def test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name( + self, + ): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(attribute="age", data_key="Years") + + data = {"Name": "Mick", "UserName": "foobar.com", "Years": "abc"} + with pytest.raises(ValidationError) as excinfo: + AliasingUserSerializer().load(data) + errors = excinfo.value.messages + assert errors["UserName"] == ["Not a valid email address."] + assert errors["Years"] == ["Not a valid integer."] + + def test_deserialize_with_data_key_param(self): + class AliasingUserSerializer(Schema): + name = fields.String(data_key="Name") + username = fields.Email(attribute="email", data_key="UserName") + years = fields.Integer(data_key="Years") + + data = {"Name": "Mick", "UserName": "foo@bar.com", "years": "42"} + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert result["email"] == "foo@bar.com" + assert "years" not in result + + def test_deserialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.load({"": "Grace"}) == {"name": "Grace"} + + def test_deserialize_with_dump_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(dump_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), dump_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer(unknown=EXCLUDE).load(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_deserialize_with_missing_param_value(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_callable(self): + bdate = dt.datetime(2017, 9, 29) + + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(load_default=lambda: bdate) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["birthdate"] == bdate + + def test_deserialize_with_missing_param_none(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_default=None, allow_none=True) + + data = {"name": "Mick"} + result = AliasingUserSerializer().load(data) + assert result["name"] == "Mick" + assert result["years"] is None + + def test_deserialization_raises_with_errors(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validator() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_raises_with_errors_with_multiple_validators(self): + bad_data = {"email": "invalid-email", "colors": "burger", "age": -1} + v = Validators() + with pytest.raises(ValidationError) as excinfo: + v.load(bad_data) + errors = excinfo.value.messages + assert "email" in errors + assert "colors" in errors + assert "age" in errors + + def test_deserialization_many_raises_errors(self): + bad_data = [ + {"email": "foo@bar.com", "colors": "red", "age": 18}, + {"email": "bad", "colors": "pizza", "age": -1}, + ] + v = Validator(many=True) + with pytest.raises(ValidationError): + v.load(bad_data) + + def test_validation_errors_are_stored(self): + def validate_field(val): + raise ValidationError("Something went wrong") + + class MySchema(Schema): + foo = fields.Field(validate=validate_field) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + errors = excinfo.value.messages + assert "Something went wrong" in errors["foo"] + + def test_multiple_errors_can_be_stored_for_a_field(self): + def validate_with_bool(n): + return False + + def validate_with_error(n): + raise ValidationError("foo is not valid") + + class MySchema(Schema): + foo = fields.Field( + required=True, validate=[validate_with_bool, validate_with_error] + ) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": "bar"}) + errors = excinfo.value.messages + + assert type(errors["foo"]) is list + assert len(errors["foo"]) == 2 + + def test_multiple_errors_can_be_stored_for_an_email_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + email = fields.Email(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"email": "foo"}) + errors = excinfo.value.messages + assert len(errors["email"]) == 2 + assert "Not a valid email address." in errors["email"][0] + + def test_multiple_errors_can_be_stored_for_a_url_field(self): + def validate_with_bool(val): + return False + + class MySchema(Schema): + url = fields.Url(validate=[validate_with_bool]) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"url": "foo"}) + errors = excinfo.value.messages + assert len(errors["url"]) == 2 + assert "Not a valid URL." in errors["url"][0] + + def test_required_value_only_passed_to_validators_if_provided(self): + class MySchema(Schema): + foo = fields.Field(required=True, validate=lambda f: False) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({}) + errors = excinfo.value.messages + # required value missing + assert len(errors["foo"]) == 1 + assert "Missing data for required field." in errors["foo"] + + @pytest.mark.parametrize("partial_schema", [True, False]) + def test_partial_deserialization(self, partial_schema): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + + schema_args = {} + load_args = {} + if partial_schema: + schema_args["partial"] = True + else: + load_args["partial"] = True + data = MySchema(**schema_args).load({"foo": 3}, **load_args) + + assert data["foo"] == 3 + assert "bar" not in data + + def test_partial_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3}, partial=tuple()) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["foo"] == 3 + assert "bar" in errors + assert "baz" in errors + + data = MySchema().load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + data = MySchema(partial=True).load({"foo": 3}, partial=("bar", "baz")) + assert data["foo"] == 3 + assert "bar" not in data + assert "baz" not in data + + def test_partial_fields_validation(self): + class MySchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field(required=True) + baz = fields.Field(required=True) + + errors = MySchema().validate({"foo": 3}, partial=tuple()) + assert "bar" in errors + assert "baz" in errors + + errors = MySchema().validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + errors = MySchema(partial=True).validate({"foo": 3}, partial=("bar", "baz")) + assert errors == {} + + def test_unknown_fields_deserialization(self): + class MySchema(Schema): + foo = fields.Integer() + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=INCLUDE) + assert data["foo"] == 3 + assert data["bar"] + + data = MySchema(unknown=INCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] + + with pytest.raises(ValidationError, match="foo"): + MySchema(unknown=INCLUDE).load({"foo": "asd", "bar": 5}) + + data = MySchema(unknown=INCLUDE, many=True).load( + [{"foo": 1}, {"foo": 3, "bar": 5}] + ) + assert "foo" in data[1] + assert "bar" in data[1] + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 3, "bar": 5}) + err = excinfo.value + assert "bar" in err.messages + assert err.messages["bar"] == ["Unknown field."] + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "abc"}, {"foo": 3, "bar": 5}]) + err = excinfo.value + assert 0 in err.messages + assert "foo" in err.messages[0] + assert err.messages[0]["foo"] == ["Not a valid integer."] + assert 1 in err.messages + assert "bar" in err.messages[1] + assert err.messages[1]["bar"] == ["Unknown field."] + + def test_unknown_fields_deserialization_precedence(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Integer() + + data = MySchema().load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert data["bar"] == 5 + + data = MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}) + assert data["foo"] == 3 + assert "bar" not in data + + data = MySchema().load({"foo": 3, "bar": 5}, unknown=EXCLUDE) + assert data["foo"] == 3 + assert "bar" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=EXCLUDE).load({"foo": 3, "bar": 5}, unknown=RAISE) + + def test_unknown_fields_deserialization_with_data_key(self): + class MySchema(Schema): + foo = fields.Integer(data_key="Foo") + + data = MySchema().load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + data = MySchema(unknown=RAISE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + with pytest.raises(ValidationError): + MySchema(unknown=RAISE).load({"foo": 1}) + + data = MySchema(unknown=INCLUDE).load({"Foo": 1}) + assert data["foo"] == 1 + assert "Foo" not in data + + def test_unknown_fields_deserialization_with_index_errors_false(self): + class MySchema(Schema): + foo = fields.Integer() + + class Meta: + unknown = RAISE + index_errors = False + + with pytest.raises(ValidationError) as excinfo: + MySchema(many=True).load([{"foo": "invalid"}, {"foo": 42, "bar": 24}]) + err = excinfo.value + assert 1 not in err.messages + assert "foo" in err.messages + assert "bar" in err.messages + assert err.messages["foo"] == ["Not a valid integer."] + assert err.messages["bar"] == ["Unknown field."] + + def test_dump_only_fields_considered_unknown(self): + class MySchema(Schema): + foo = fields.Int(dump_only=True) + + with pytest.raises(ValidationError) as excinfo: + MySchema().load({"foo": 42}) + err = excinfo.value + assert "foo" in err.messages + assert err.messages["foo"] == ["Unknown field."] + + # When unknown = INCLUDE, dump-only fields are included as unknown + # without any validation. + data = MySchema(unknown=INCLUDE).load({"foo": "LOL"}) + assert data["foo"] == "LOL" + + def test_unknown_fields_do_not_unpack_dotted_names(self): + class MySchema(Schema): + class Meta: + unknown = INCLUDE + + foo = fields.Str() + bar = fields.Str(data_key="bar.baz") + + # dotted names are still supported + data = MySchema().load({"foo": "hi", "bar.baz": "okay"}) + assert data == {"foo": "hi", "bar": "okay"} + + # but extra keys included via unknown=INCLUDE are not transformed into nested dicts + data = MySchema().load({"foo": "hi", "bar.baz": "okay", "alpha.beta": "woah!"}) + assert data == {"foo": "hi", "bar": "okay", "alpha.beta": "woah!"} + + +validators_gen = (func for func in [lambda x: x <= 24, lambda x: 18 <= x]) + +validators_gen_float = (func for func in [lambda f: f <= 4.1, lambda f: f >= 1.0]) + +validators_gen_str = ( + func for func in [lambda n: len(n) == 3, lambda n: n[1].lower() == "o"] +) + + +class TestValidation: + def test_integer_with_validator(self): + field = fields.Integer(validate=lambda x: 18 <= x <= 24) + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Integer(validate=[lambda x: x <= 24, lambda x: 18 <= x]), + fields.Integer(validate=(lambda x: x <= 24, lambda x: 18 <= x)), + fields.Integer(validate=validators_gen), + ], + ) + def test_integer_with_validators(self, field): + out = field.deserialize("20") + assert out == 20 + with pytest.raises(ValidationError): + field.deserialize(25) + + @pytest.mark.parametrize( + "field", + [ + fields.Float(validate=[lambda f: f <= 4.1, lambda f: f >= 1.0]), + fields.Float(validate=(lambda f: f <= 4.1, lambda f: f >= 1.0)), + fields.Float(validate=validators_gen_float), + ], + ) + def test_float_with_validators(self, field): + assert field.deserialize(3.14) + with pytest.raises(ValidationError): + field.deserialize(4.2) + + def test_string_validator(self): + field = fields.String(validate=lambda n: len(n) == 3) + assert field.deserialize("Joe") == "Joe" + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_function_validator(self): + field = fields.Function( + lambda d: d.name.upper(), validate=lambda n: len(n) == 3 + ) + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + @pytest.mark.parametrize( + "field", + [ + fields.Function( + lambda d: d.name.upper(), + validate=[lambda n: len(n) == 3, lambda n: n[1].lower() == "o"], + ), + fields.Function( + lambda d: d.name.upper(), + validate=(lambda n: len(n) == 3, lambda n: n[1].lower() == "o"), + ), + fields.Function(lambda d: d.name.upper(), validate=validators_gen_str), + ], + ) + def test_function_validators(self, field): + assert field.deserialize("joe") + with pytest.raises(ValidationError): + field.deserialize("joseph") + + def test_method_validator(self): + class MethodSerializer(Schema): + name = fields.Method( + "get_name", deserialize="get_name", validate=lambda n: len(n) == 3 + ) + + def get_name(self, val): + return val.upper() + + assert MethodSerializer().load({"name": "joe"}) + with pytest.raises(ValidationError, match="Invalid value."): + MethodSerializer().load({"name": "joseph"}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/269 + def test_nested_data_is_stored_when_validation_fails(self): + class SchemaA(Schema): + x = fields.Integer() + y = fields.Integer(validate=lambda n: n > 0) + z = fields.Integer() + + class SchemaB(Schema): + w = fields.Integer() + n = fields.Nested(SchemaA) + + sch = SchemaB() + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": 89, "z": None}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "z" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "y": 89}} + + with pytest.raises(ValidationError) as excinfo: + sch.load({"w": 90, "n": {"x": 90, "y": -1, "z": 180}}) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "y" in errors["n"] + assert data == {"w": 90, "n": {"x": 90, "z": 180}} + + def test_false_value_validation(self): + class Sch(Schema): + lamb = fields.Raw(validate=lambda x: x is False) + equal = fields.Raw(validate=Equal(False)) + + errors = Sch().validate({"lamb": False, "equal": False}) + assert not errors + errors = Sch().validate({"lamb": True, "equal": True}) + assert "lamb" in errors + assert errors["lamb"] == ["Invalid value."] + assert "equal" in errors + assert errors["equal"] == ["Must be equal to False."] + + def test_nested_partial_load(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # Partial loading shouldn't generate any errors. + result = SchemaB().load(b_dict, partial=True) + assert result["z"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaB().load(b_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["z"]["y"] == 42 + assert "z" in errors + assert "x" in errors["z"] + + def test_deeply_nested_partial_load(self): + class SchemaC(Schema): + x = fields.Integer(required=True) + y = fields.Integer() + + class SchemaB(Schema): + c = fields.Nested(SchemaC) + + class SchemaA(Schema): + b = fields.Nested(SchemaB) + + a_dict = {"b": {"c": {"y": 42}}} + # Partial loading shouldn't generate any errors. + result = SchemaA().load(a_dict, partial=True) + assert result["b"]["c"]["y"] == 42 + # Non partial loading should complain about missing values. + with pytest.raises(ValidationError) as excinfo: + SchemaA().load(a_dict) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert data["b"]["c"]["y"] == 42 + assert "b" in errors + assert "c" in errors["b"] + assert "x" in errors["b"]["c"] + + def test_nested_partial_tuple(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA) + + b_dict = {"z": {"y": 42}} + # If we ignore the missing z.x, z.y should still load. + result = SchemaB().load(b_dict, partial=("z.x",)) + assert result["z"]["y"] == 42 + # If we ignore a missing z.y we should get a validation error. + with pytest.raises(ValidationError): + SchemaB().load(b_dict, partial=("z.y",)) + + def test_nested_partial_default(self): + class SchemaA(Schema): + x = fields.Integer(required=True) + y = fields.Integer(required=True) + + class SchemaB(Schema): + z = fields.Nested(SchemaA(partial=("x",))) + + b_dict = {"z": {"y": 42}} + # Nested partial args should be respected. + result = SchemaB().load(b_dict) + assert result["z"]["y"] == 42 + with pytest.raises(ValidationError): + SchemaB().load({"z": {"x": 0}}) + + +@pytest.mark.parametrize("FieldClass", ALL_FIELDS) +def test_required_field_failure(FieldClass): # noqa + class RequireSchema(Schema): + age = FieldClass(required=True) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + assert "Missing data for required field." in errors["age"] + + +@pytest.mark.parametrize( + "message", + [ + "My custom required message", + {"error": "something", "code": 400}, + ["first error", "second error"], + ], +) +def test_required_message_can_be_changed(message): + class RequireSchema(Schema): + age = fields.Integer(required=True, error_messages={"required": message}) + + user_data = {"name": "Phil"} + with pytest.raises(ValidationError) as excinfo: + RequireSchema().load(user_data) + errors = excinfo.value.messages + expected = [message] if isinstance(message, str) else message + assert expected == errors["age"] + + +@pytest.mark.parametrize("unknown", (EXCLUDE, INCLUDE, RAISE)) +@pytest.mark.parametrize("data", [True, False, 42, None, []]) +def test_deserialize_raises_exception_if_input_type_is_incorrect(data, unknown): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + + with pytest.raises(ValidationError, match="Invalid input type.") as excinfo: + MySchema(unknown=unknown).load(data) + exc = excinfo.value + assert list(exc.messages.keys()) == ["_schema"] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_error_store.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_error_store.py new file mode 100644 index 0000000000000000000000000000000000000000..8315bf2a93caacb0026c4dab6fd395e9b7a56e30 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_error_store.py @@ -0,0 +1,143 @@ +from collections import namedtuple + +from marshmallow import missing +from marshmallow.error_store import merge_errors + + +def test_missing_is_falsy(): + assert bool(missing) is False + + +CustomError = namedtuple("CustomError", ["code", "message"]) + + +class TestMergeErrors: + def test_merging_none_and_string(self): + assert "error1" == merge_errors(None, "error1") + + def test_merging_none_and_custom_error(self): + assert CustomError(123, "error1") == merge_errors( + None, CustomError(123, "error1") + ) + + def test_merging_none_and_list(self): + assert ["error1", "error2"] == merge_errors(None, ["error1", "error2"]) + + def test_merging_none_and_dict(self): + assert {"field1": "error1"} == merge_errors(None, {"field1": "error1"}) + + def test_merging_string_and_none(self): + assert "error1" == merge_errors("error1", None) + + def test_merging_custom_error_and_none(self): + assert CustomError(123, "error1") == merge_errors( + CustomError(123, "error1"), None + ) + + def test_merging_list_and_none(self): + assert ["error1", "error2"] == merge_errors(["error1", "error2"], None) + + def test_merging_dict_and_none(self): + assert {"field1": "error1"} == merge_errors({"field1": "error1"}, None) + + def test_merging_string_and_string(self): + assert ["error1", "error2"] == merge_errors("error1", "error2") + + def test_merging_custom_error_and_string(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), "error2" + ) + + def test_merging_string_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + "error1", CustomError(123, "error2") + ) + + def test_merging_custom_error_and_custom_error(self): + assert [CustomError(123, "error1"), CustomError(456, "error2")] == merge_errors( + CustomError(123, "error1"), CustomError(456, "error2") + ) + + def test_merging_string_and_list(self): + assert ["error1", "error2"] == merge_errors("error1", ["error2"]) + + def test_merging_string_and_dict(self): + assert {"_schema": "error1", "field1": "error2"} == merge_errors( + "error1", {"field1": "error2"} + ) + + def test_merging_string_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + "error1", {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_custom_error_and_list(self): + assert [CustomError(123, "error1"), "error2"] == merge_errors( + CustomError(123, "error1"), ["error2"] + ) + + def test_merging_custom_error_and_dict(self): + assert { + "_schema": CustomError(123, "error1"), + "field1": "error2", + } == merge_errors(CustomError(123, "error1"), {"field1": "error2"}) + + def test_merging_custom_error_and_dict_with_schema_error(self): + assert { + "_schema": [CustomError(123, "error1"), "error2"], + "field1": "error3", + } == merge_errors( + CustomError(123, "error1"), {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_list_and_string(self): + assert ["error1", "error2"] == merge_errors(["error1"], "error2") + + def test_merging_list_and_custom_error(self): + assert ["error1", CustomError(123, "error2")] == merge_errors( + ["error1"], CustomError(123, "error2") + ) + + def test_merging_list_and_list(self): + assert ["error1", "error2"] == merge_errors(["error1"], ["error2"]) + + def test_merging_list_and_dict(self): + assert {"_schema": ["error1"], "field1": "error2"} == merge_errors( + ["error1"], {"field1": "error2"} + ) + + def test_merging_list_and_dict_with_schema_error(self): + assert {"_schema": ["error1", "error2"], "field1": "error3"} == merge_errors( + ["error1"], {"_schema": "error2", "field1": "error3"} + ) + + def test_merging_dict_and_string(self): + assert {"_schema": "error2", "field1": "error1"} == merge_errors( + {"field1": "error1"}, "error2" + ) + + def test_merging_dict_and_custom_error(self): + assert { + "_schema": CustomError(123, "error2"), + "field1": "error1", + } == merge_errors({"field1": "error1"}, CustomError(123, "error2")) + + def test_merging_dict_and_list(self): + assert {"_schema": ["error2"], "field1": "error1"} == merge_errors( + {"field1": "error1"}, ["error2"] + ) + + def test_merging_dict_and_dict(self): + assert { + "field1": "error1", + "field2": ["error2", "error3"], + "field3": "error4", + } == merge_errors( + {"field1": "error1", "field2": "error2"}, + {"field2": "error3", "field3": "error4"}, + ) + + def test_deep_merging_dicts(self): + assert {"field1": {"field2": ["error1", "error2"]}} == merge_errors( + {"field1": {"field2": "error1"}}, {"field1": {"field2": "error2"}} + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_exceptions.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_exceptions.py new file mode 100644 index 0000000000000000000000000000000000000000..e4f144a118b9c11eed490ba76159d2a152110f2f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_exceptions.py @@ -0,0 +1,42 @@ +import pytest + +from marshmallow.exceptions import ValidationError + + +class TestValidationError: + def test_stores_message_in_list(self): + err = ValidationError("foo") + assert err.messages == ["foo"] + + def test_can_pass_list_of_messages(self): + err = ValidationError(["foo", "bar"]) + assert err.messages == ["foo", "bar"] + + def test_stores_dictionaries(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages == messages + + def test_can_store_field_name(self): + err = ValidationError("invalid email", field_name="email") + assert err.field_name == "email" + + def test_str(self): + err = ValidationError("invalid email") + assert str(err) == "invalid email" + + err2 = ValidationError("invalid email", "email") + assert str(err2) == "invalid email" + + def test_stores_dictionaries_in_messages_dict(self): + messages = {"user": {"email": ["email is invalid"]}} + err = ValidationError(messages) + assert err.messages_dict == messages + + def test_messages_dict_type_error_on_badval(self): + err = ValidationError("foo") + with pytest.raises(TypeError) as excinfo: + err.messages_dict # noqa: B018 + assert "cannot access 'messages_dict' when 'messages' is of type list" in str( + excinfo.value + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_fields.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_fields.py new file mode 100644 index 0000000000000000000000000000000000000000..cb1d463860ecf68fba1e26bacbcb705d093ab7e3 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_fields.py @@ -0,0 +1,665 @@ +import pytest + +from marshmallow import ( + EXCLUDE, + INCLUDE, + RAISE, + Schema, + ValidationError, + fields, + missing, +) +from marshmallow.exceptions import StringNotCollectionError +from marshmallow.orderedset import OrderedSet +from tests.base import ALL_FIELDS + + +@pytest.mark.parametrize( + ("alias", "field"), + [ + (fields.Int, fields.Integer), + (fields.Str, fields.String), + (fields.Bool, fields.Boolean), + (fields.URL, fields.Url), + ], +) +def test_field_aliases(alias, field): + assert alias is field + + +class TestField: + def test_repr(self): + default = "œ∑´" + field = fields.Field(dump_default=default, attribute=None) + assert repr(field) == ( + f"" + ) + int_field = fields.Integer(validate=lambda x: True) + assert " 3) + bar = fields.Int(validate=lambda x: x > 3) + + sch = MySchema() + valid = {"foo": "loll", "bar": 42} + invalid = {"foo": "lol", "bar": 3} + errors = sch.validate([valid, invalid], many=True) + + assert 1 in errors + assert len(errors[1]) == 2 + assert "foo" in errors[1] + assert "bar" in errors[1] + + +def test_dump_returns_a_dict(user): + s = UserSchema() + result = s.dump(user) + assert type(result) is dict + + +def test_dumps_returns_a_string(user): + s = UserSchema() + result = s.dumps(user) + assert type(result) is str + + +def test_dumping_single_object_with_collection_schema(user): + s = UserSchema(many=True) + result = s.dump(user, many=False) + assert type(result) is dict + assert result == UserSchema().dump(user) + + +def test_loading_single_object_with_collection_schema(): + s = UserSchema(many=True) + in_data = {"name": "Mick", "email": "mick@stones.com"} + result = s.load(in_data, many=False) + assert type(result) is User + assert result.name == UserSchema().load(in_data).name + + +def test_dumps_many(): + s = UserSchema() + u1, u2 = User("Mick"), User("Keith") + json_result = s.dumps([u1, u2], many=True) + data = json.loads(json_result) + assert len(data) == 2 + assert data[0] == s.dump(u1) + + +def test_load_returns_an_object(): + s = UserSchema() + result = s.load({"name": "Monty"}) + assert type(result) is User + + +def test_load_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + result = s.load(in_data, many=True) + assert type(result) is list + assert type(result[0]) is User + assert result[0].name == "Mick" + + +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), [], set(), "lol")) +def test_load_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch().load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == {} + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/906 +@pytest.mark.parametrize("val", (None, False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_invalid_input_type(val): + class Sch(Schema): + name = fields.Str() + + with pytest.raises(ValidationError) as e: + Sch(many=True).load(val) + assert e.value.messages == {"_schema": ["Invalid input type."]} + assert e.value.valid_data == [] + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_empty_collection(val): + class Sch(Schema): + name = fields.Str() + + assert Sch(many=True).load(val) == [] + + +@pytest.mark.parametrize("val", (False, 1, 1.2, object(), {}, {"1": 2}, "lol")) +def test_load_many_in_nested_invalid_input_type(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + with pytest.raises(ValidationError) as e: + Outer().load({"list1": val, "list2": val}) + # TODO: Error messages should be identical (#779) + assert e.value.messages == { + "list1": ["Not a valid list."], + "list2": ["Invalid type."], + } + + +@pytest.mark.parametrize("val", ([], set())) +def test_load_many_in_nested_empty_collection(val): + class Inner(Schema): + name = fields.String() + + class Outer(Schema): + list1 = fields.List(fields.Nested(Inner)) + list2 = fields.Nested(Inner, many=True) + + assert Outer().load({"list1": val, "list2": val}) == {"list1": [], "list2": []} + + +def test_loads_returns_a_user(): + s = UserSchema() + result = s.loads(json.dumps({"name": "Monty"})) + assert type(result) is User + + +def test_loads_many(): + s = UserSchema() + in_data = [{"name": "Mick"}, {"name": "Keith"}] + in_json_data = json.dumps(in_data) + result = s.loads(in_json_data, many=True) + assert type(result) is list + assert result[0].name == "Mick" + + +def test_loads_deserializes_from_json(): + user_dict = {"name": "Monty", "age": "42.3"} + user_json = json.dumps(user_dict) + result = UserSchema().loads(user_json) + assert isinstance(result, User) + assert result.name == "Monty" + assert math.isclose(result.age, 42.3) + + +def test_serializing_none(): + class MySchema(Schema): + id = fields.Str(dump_default="no-id") + num = fields.Int() + name = fields.Str() + + data = UserSchema().dump(None) + assert data == {"id": "no-id"} + + +def test_default_many_symmetry(): + """The dump/load(s) methods should all default to the many value of the schema.""" + s_many = UserSchema(many=True, only=("name",)) + s_single = UserSchema(only=("name",)) + u1, u2 = User("King Arthur"), User("Sir Lancelot") + s_single.load(s_single.dump(u1)) + s_single.loads(s_single.dumps(u1)) + s_many.load(s_many.dump([u1, u2])) + s_many.loads(s_many.dumps([u1, u2])) + + +def test_on_bind_field_hook(): + class MySchema(Schema): + foo = fields.Str() + + def on_bind_field(self, field_name, field_obj): + assert field_obj.parent is self + field_obj.metadata["fname"] = field_name + + schema = MySchema() + assert schema.fields["foo"].metadata["fname"] == "foo" + + +def test_nested_on_bind_field_hook(): + class MySchema(Schema): + class NestedSchema(Schema): + bar = fields.Str() + + def on_bind_field(self, field_name, field_obj): + field_obj.metadata["fname"] = self.context["fname"] + + foo = fields.Nested(NestedSchema) + + schema1 = MySchema(context={"fname": "foobar"}) + schema2 = MySchema(context={"fname": "quxquux"}) + + assert schema1.fields["foo"].schema.fields["bar"].metadata["fname"] == "foobar" + assert schema2.fields["foo"].schema.fields["bar"].metadata["fname"] == "quxquux" + + +class TestValidate: + def test_validate_raises_with_errors_dict(self): + s = UserSchema() + errors = s.validate({"email": "bad-email", "name": "Valid Name"}) + assert type(errors) is dict + assert "email" in errors + assert "name" not in errors + + valid_data = {"name": "Valid Name", "email": "valid@email.com"} + errors = s.validate(valid_data) + assert errors == {} + + def test_validate_many(self): + s = UserSchema(many=True) + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 in errors + assert "email" in errors[1] + + def test_validate_many_doesnt_store_index_if_index_errors_option_is_false(self): + class NoIndex(Schema): + email = fields.Email() + + class Meta: + index_errors = False + + s = NoIndex() + in_data = [ + {"name": "Valid Name", "email": "validemail@hotmail.com"}, + {"name": "Valid Name2", "email": "invalid"}, + ] + errors = s.validate(in_data, many=True) + assert 1 not in errors + assert "email" in errors + + def test_validate(self): + s = UserSchema() + errors = s.validate({"email": "bad-email"}) + assert errors == {"email": ["Not a valid email address."]} + + def test_validate_required(self): + class MySchema(Schema): + foo = fields.Field(required=True) + + s = MySchema() + errors = s.validate({"bar": 42}) + assert "foo" in errors + assert "required" in errors["foo"][0] + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_fields_are_not_copies(SchemaClass): + s = SchemaClass() + s2 = SchemaClass() + assert s.fields is not s2.fields + + +def test_dumps_returns_json(user): + ser = UserSchema() + serialized = ser.dump(user) + json_data = ser.dumps(user) + assert type(json_data) is str + expected = json.dumps(serialized) + assert json_data == expected + + +def test_naive_datetime_field(user, serialized_user): + expected = utils.isoformat(user.created) + assert serialized_user["created"] == expected + + +def test_datetime_formatted_field(user, serialized_user): + result = serialized_user["created_formatted"] + assert result == user.created.strftime("%Y-%m-%d") + + +def test_datetime_iso_field(user, serialized_user): + assert serialized_user["created_iso"] == utils.isoformat(user.created) + + +def test_tz_datetime_field(user, serialized_user): + # Datetime is corrected back to GMT + expected = utils.isoformat(user.updated) + assert serialized_user["updated"] == expected + + +def test_class_variable(serialized_user): + assert serialized_user["species"] == "Homo sapiens" + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serialize_many(SchemaClass): + user1 = User(name="Mick", age=123) + user2 = User(name="Keith", age=456) + users = [user1, user2] + serialized = SchemaClass(many=True).dump(users) + assert len(serialized) == 2 + assert serialized[0]["name"] == "Mick" + assert serialized[1]["name"] == "Keith" + + +def test_inheriting_schema(user): + sch = ExtendedUserSchema() + result = sch.dump(user) + assert result["name"] == user.name + user.is_old = True + result = sch.dump(user) + assert result["is_old"] is True + + +def test_custom_field(serialized_user, user): + assert serialized_user["uppername"] == user.name.upper() + + +def test_url_field(serialized_user, user): + assert serialized_user["homepage"] == user.homepage + + +def test_relative_url_field(): + u = {"name": "John", "homepage": "/foo"} + UserRelativeUrlSchema().load(u) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_stores_invalid_url_error(SchemaClass): + user = {"name": "Steve", "homepage": "www.foo.com"} + with pytest.raises(ValidationError) as excinfo: + SchemaClass().load(user) + errors = excinfo.value.messages + assert "homepage" in errors + expected = ["Not a valid URL."] + assert errors["homepage"] == expected + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_email_field(SchemaClass): + u = User("John", email="john@example.com") + s = SchemaClass().dump(u) + assert s["email"] == "john@example.com" + + +def test_stored_invalid_email(): + u = {"name": "John", "email": "johnexample.com"} + with pytest.raises(ValidationError) as excinfo: + UserSchema().load(u) + errors = excinfo.value.messages + assert "email" in errors + assert errors["email"][0] == "Not a valid email address." + + +def test_integer_field(): + u = User("John", age=42.3) + serialized = UserIntSchema().dump(u) + assert type(serialized["age"]) is int + assert serialized["age"] == 42 + + +def test_as_string(): + u = User("John", age=42.3) + serialized = UserFloatStringSchema().dump(u) + assert type(serialized["age"]) is str + assert math.isclose(float(serialized["age"]), 42.3) + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_method_field(SchemaClass, serialized_user): + assert serialized_user["is_old"] is False + u = User("Joe", age=81) + assert SchemaClass().dump(u)["is_old"] is True + + +def test_function_field(serialized_user, user): + assert serialized_user["lowername"] == user.name.lower() + + +def test_fields_must_be_declared_as_instances(user): + class BadUserSchema(Schema): + name = fields.String + + with pytest.raises( + TypeError, match='Field for "name" must be declared as a Field instance' + ): + BadUserSchema().dump(user) + + +# regression test +def test_bind_field_does_not_swallow_typeerror(): + class MySchema(Schema): + name = fields.Str() + + def on_bind_field(self, field_name, field_obj): + raise TypeError("boom") + + with pytest.raises(TypeError, match="boom"): + MySchema() + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_serializing_generator(SchemaClass): + users = [User("Foo"), User("Bar")] + user_gen = (u for u in users) + s = SchemaClass(many=True).dump(user_gen) + assert len(s) == 2 + assert s[0] == SchemaClass().dump(users[0]) + + +def test_serializing_empty_list_returns_empty_list(): + assert UserSchema(many=True).dump([]) == [] + assert UserMetaSchema(many=True).dump([]) == [] + + +def test_serializing_dict(): + user = { + "name": "foo", + "email": "foo@bar.com", + "age": 42, + "various_data": {"foo": "bar"}, + } + data = UserSchema().dump(user) + assert data["name"] == "foo" + assert data["age"] == 42 + assert data["various_data"] == {"foo": "bar"} + + +def test_serializing_dict_with_meta_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo", "bar") + + sch = MySchema() + data = sch.dump({"foo": 42, "bar": 24, "baz": 424}) + assert data["foo"] == 42 + assert data["bar"] == 24 + assert "baz" not in data + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_exclude_in_init(SchemaClass, user): + s = SchemaClass(exclude=("age", "homepage")).dump(user) + assert "homepage" not in s + assert "age" not in s + assert "name" in s + + +@pytest.mark.parametrize("SchemaClass", [UserSchema, UserMetaSchema]) +def test_only_in_init(SchemaClass, user): + s = SchemaClass(only=("name", "age")).dump(user) + assert "homepage" not in s + assert "name" in s + assert "age" in s + + +def test_invalid_only_param(user): + with pytest.raises(ValueError): + UserSchema(only=("_invalid", "name")).dump(user) + + +def test_can_serialize_uuid(serialized_user, user): + assert serialized_user["uid"] == str(user.uid) + + +def test_can_serialize_time(user, serialized_user): + expected = user.time_registered.isoformat()[:15] + assert serialized_user["time_registered"] == expected + + +def test_json_module_is_deprecated(): + with pytest.deprecated_call(): + + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + json_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_render_module(): + class UserJSONSchema(Schema): + name = fields.String() + + class Meta: + render_module = mockjson + + user = User("Joe") + s = UserJSONSchema() + result = s.dumps(user) + assert result == mockjson.dumps("val") + + +def test_custom_error_message(): + class ErrorSchema(Schema): + email = fields.Email(error_messages={"invalid": "Invalid email"}) + homepage = fields.Url(error_messages={"invalid": "Bad homepage."}) + balance = fields.Decimal(error_messages={"invalid": "Bad balance."}) + + u = {"email": "joe.net", "homepage": "joe@example.com", "balance": "blah"} + s = ErrorSchema() + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert "Bad balance." in errors["balance"] + assert "Bad homepage." in errors["homepage"] + assert "Invalid email" in errors["email"] + + +def test_custom_unknown_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"unknown": custom_message} + name = fields.String() + + s = ErrorSchema() + u = {"name": "Joe", "age": 13} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["age"] + + +def test_custom_type_error_message(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema() + u = ["Joe"] + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_type_error_message_with_many(): + custom_message = "custom error message." + + class ErrorSchema(Schema): + error_messages = {"type": custom_message} + name = fields.String() + + s = ErrorSchema(many=True) + u = {"name": "Joe"} + with pytest.raises(ValidationError) as excinfo: + s.load(u) + errors = excinfo.value.messages + assert custom_message in errors["_schema"] + + +def test_custom_error_messages_with_inheritance(): + parent_type_message = "parent type error message." + parent_unknown_message = "parent unknown error message." + child_type_message = "child type error message." + + class ParentSchema(Schema): + error_messages = { + "type": parent_type_message, + "unknown": parent_unknown_message, + } + name = fields.String() + + class ChildSchema(ParentSchema): + error_messages = {"type": child_type_message} + + unknown_user = {"name": "Eleven", "age": 12} + type_user = 11 + + parent_schema = ParentSchema() + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + parent_schema.load(type_user) + assert parent_type_message in excinfo.value.messages["_schema"] + + child_schema = ChildSchema() + with pytest.raises(ValidationError) as excinfo: + child_schema.load(unknown_user) + assert parent_unknown_message in excinfo.value.messages["age"] + with pytest.raises(ValidationError) as excinfo: + child_schema.load(type_user) + assert child_type_message in excinfo.value.messages["_schema"] + + +def test_load_errors_with_many(): + class ErrorSchema(Schema): + email = fields.Email() + + data = [ + {"email": "bademail"}, + {"email": "goo@email.com"}, + {"email": "anotherbademail"}, + ] + + with pytest.raises(ValidationError) as excinfo: + ErrorSchema(many=True).load(data) + errors = excinfo.value.messages + assert 0 in errors + assert 2 in errors + assert "Not a valid email address." in errors[0]["email"][0] + assert "Not a valid email address." in errors[2]["email"][0] + + +def test_error_raised_if_fields_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = "name" + + +def test_error_raised_if_additional_option_is_not_list(): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + additional = "email" + + +def test_nested_custom_set_in_exclude_reusing_schema(): + class CustomSet: + # This custom set is to allow the obj check in BaseSchema.__filter_fields + # to pass, since it'll be a valid instance, and this class overrides + # getitem method to allow the hasattr check to pass too, which will try + # to access the first obj index and will simulate a IndexError throwing. + # e.g. SqlAlchemy.Query is a valid use case for this 'obj'. + + def __getitem__(self, item): + return [][item] + + class ChildSchema(Schema): + foo = fields.Field(required=True) + bar = fields.Field() + + class Meta: + only = ("bar",) + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, many=True, exclude=("foo",)) + + sch = ParentSchema() + obj = dict(child=CustomSet()) + sch.dumps(obj) + data = dict(child=[{"bar": 1}]) + sch.load(data, partial=True) + + +def test_nested_only(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(only=("blubb.foo", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_only_empty_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("bar",)) + + sch = ParentSchema(only=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" not in child + assert "baz" not in child + + +def test_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(exclude=("bli", "blubb.baz")) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("baz",)) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_and_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema(only=("bla", "blubb.foo", "blubb.bar"), exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_only_then_exclude_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, only=("foo", "bar")) + + sch = ParentSchema(exclude=("blubb.foo",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_then_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema, exclude=("foo",)) + + sch = ParentSchema(only=("blubb.bar",)) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + + +def test_nested_exclude_and_only_inheritance(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + ban = fields.Field() + fuu = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "bar", "baz", "ban"), exclude=("foo",) + ) + + sch = ParentSchema( + only=("blubb.foo", "blubb.bar", "blubb.baz"), exclude=("blubb.baz",) + ) + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + result = sch.dump(data) + assert "bla" not in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" not in child + assert "ban" not in child + assert "fuu" not in child + + +# https://github.com/marshmallow-code/marshmallow/issues/1160 +def test_nested_instance_many(): + class BookSchema(Schema): + id = fields.Int() + title = fields.String() + + class UserSchema(Schema): + id = fields.Int() + name = fields.String() + books = fields.Nested(BookSchema(many=True)) + + books = [{"id": 1, "title": "First book"}, {"id": 2, "title": "Second book"}] + user = {"id": 1, "name": "Peter", "books": books} + + user_dump = UserSchema().dump(user) + assert user_dump["books"] == books + + user_load = UserSchema().load(user_dump) + assert user_load == user + + +def test_nested_instance_only(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), only=("last",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_nested_instance_exclude(): + class ArtistSchema(Schema): + first = fields.Str() + last = fields.Str() + + class AlbumSchema(Schema): + title = fields.Str() + artist = fields.Nested(ArtistSchema(), exclude=("first",)) + + schema = AlbumSchema() + album = {"title": "Hunky Dory", "artist": {"last": "Bowie"}} + loaded = schema.load(album) + assert loaded == album + full_album = {"title": "Hunky Dory", "artist": {"first": "David", "last": "Bowie"}} + assert schema.dump(full_album) == album + + +def test_meta_nested_exclude(): + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + class Meta: + exclude = ("blubb.foo",) + + data = dict(bla=1, bli=2, blubb=dict(foo=42, bar=24, baz=242)) + + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + # Test fields with dot notations in Meta.exclude on multiple instantiations + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1212 + sch = ParentSchema() + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" in result + child = result["blubb"] + assert "foo" not in child + assert "bar" in child + assert "baz" in child + + +def test_nested_custom_set_not_implementing_getitem(): + # This test checks that marshmallow can serialize implementations of + # :mod:`collections.abc.MutableSequence`, with ``__getitem__`` arguments + # that are not integers. + + class ListLikeParent: + """ + Implements a list-like object that can get children using a + non-integer key + """ + + def __init__(self, required_key, child): + """ + :param required_key: The key to use in ``__getitem__`` in order + to successfully get the ``child`` + :param child: The return value of the ``child`` if + ``__getitem__`` succeeds + """ + self.children = {required_key: child} + + class Child: + """ + Implements an object with some attribute + """ + + def __init__(self, attribute): + """ + :param str attribute: The attribute to initialize + """ + self.attribute = attribute + + class ChildSchema(Schema): + """ + The marshmallow schema for the child + """ + + attribute = fields.Str() + + class ParentSchema(Schema): + """ + The schema for the parent + """ + + children = fields.Nested(ChildSchema, many=True) + + attribute = "Foo" + required_key = "key" + child = Child(attribute) + + parent = ListLikeParent(required_key, child) + + ParentSchema().dump(parent) + + +def test_deeply_nested_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested(ChildSchema) + + sch = ParentSchema( + only=("bla", "blubb.foo", "blubb.flubb.goo", "blubb.flubb.gah"), + exclude=("blubb.flubb.goo",), + ) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_nested_lambda(): + class ChildSchema(Schema): + id = fields.Str() + name = fields.Str() + parent = fields.Nested(lambda: ParentSchema(only=("id",)), dump_only=True) + siblings = fields.List(fields.Nested(lambda: ChildSchema(only=("id", "name")))) + + class ParentSchema(Schema): + id = fields.Str() + spouse = fields.Nested(lambda: ParentSchema(only=("id",))) + children = fields.List( + fields.Nested(lambda: ChildSchema(only=("id", "parent", "siblings"))) + ) + + sch = ParentSchema() + data_to_load = { + "id": "p1", + "spouse": {"id": "p2"}, + "children": [{"id": "c1", "siblings": [{"id": "c2", "name": "sis"}]}], + } + loaded = sch.load(data_to_load) + assert loaded == data_to_load + + data_to_dump = dict( + id="p2", + spouse=dict(id="p2"), + children=[ + dict( + id="c1", + name="bar", + parent=dict(id="p2"), + siblings=[dict(id="c2", name="sis")], + ) + ], + ) + dumped = sch.dump(data_to_dump) + assert dumped == { + "id": "p2", + "spouse": {"id": "p2"}, + "children": [ + { + "id": "c1", + "parent": {"id": "p2"}, + "siblings": [{"id": "c2", "name": "sis"}], + } + ], + } + + +@pytest.mark.parametrize("data_key", ("f1", "f5", None)) +def test_data_key_collision(data_key): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(data_key=data_key) + f3 = fields.Field(data_key="f5") + f4 = fields.Field(data_key="f1", load_only=True) + + if data_key is None: + MySchema() + else: + with pytest.raises(ValueError, match=data_key): + MySchema() + + +@pytest.mark.parametrize("attribute", ("f1", "f5", None)) +def test_attribute_collision(attribute): + class MySchema(Schema): + f1 = fields.Field() + f2 = fields.Field(attribute=attribute) + f3 = fields.Field(attribute="f5") + f4 = fields.Field(attribute="f1", dump_only=True) + + if attribute is None: + MySchema() + else: + with pytest.raises(ValueError, match=attribute): + MySchema() + + +class TestDeeplyNestedLoadOnly: + @pytest.fixture() + def schema(self): + class GrandChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + grand_child = fields.Nested(GrandChildSchema, unknown=EXCLUDE) + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.Nested(ChildSchema, unknown=EXCLUDE) + + return ParentSchema( + dump_only=( + "str_dump_only", + "child.str_dump_only", + "child.grand_child.str_dump_only", + ), + load_only=( + "str_load_only", + "child.str_load_only", + "child.grand_child.str_load_only", + ), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + grand_child=dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ), + ), + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_load_only" not in grand_child + assert "str_dump_only" in grand_child + assert "str_regular" in grand_child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + grand_child = child["grand_child"] + assert "str_dump_only" not in grand_child + assert "str_load_only" in grand_child + assert "str_regular" in grand_child + + +class TestDeeplyNestedListLoadOnly: + @pytest.fixture() + def schema(self): + class ChildSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + class ParentSchema(Schema): + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + child = fields.List(fields.Nested(ChildSchema, unknown=EXCLUDE)) + + return ParentSchema( + dump_only=("str_dump_only", "child.str_dump_only"), + load_only=("str_load_only", "child.str_load_only"), + ) + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + child=[ + dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + ], + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_load_only" not in child + assert "str_dump_only" in child + assert "str_regular" in child + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + child = result["child"][0] + assert "str_dump_only" not in child + assert "str_load_only" in child + assert "str_regular" in child + + +def test_nested_constructor_only_and_exclude(): + class GrandChildSchema(Schema): + goo = fields.Field() + gah = fields.Field() + bah = fields.Field() + + class ChildSchema(Schema): + foo = fields.Field() + bar = fields.Field() + flubb = fields.Nested(GrandChildSchema) + + class ParentSchema(Schema): + bla = fields.Field() + bli = fields.Field() + blubb = fields.Nested( + ChildSchema, only=("foo", "flubb.goo", "flubb.gah"), exclude=("flubb.goo",) + ) + + sch = ParentSchema(only=("bla", "blubb")) + data = dict(bla=1, bli=2, blubb=dict(foo=3, bar=4, flubb=dict(goo=5, gah=6, bah=7))) + result = sch.dump(data) + assert "bla" in result + assert "blubb" in result + assert "bli" not in result + child = result["blubb"] + assert "foo" in child + assert "flubb" in child + assert "bar" not in child + grand_child = child["flubb"] + assert "gah" in grand_child + assert "goo" not in grand_child + assert "bah" not in grand_child + + +def test_only_and_exclude(): + class MySchema(Schema): + foo = fields.Field() + bar = fields.Field() + baz = fields.Field() + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + sch = MySchema(only=("bar", "baz"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "baz" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_fields(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + fields = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foo", "par"), exclude=("ban",)) + + assert "foo" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + sch = MySchema(only=("foo", "bar"), exclude=("bar",)) + data = dict(foo=42, bar=24, baz=242) + result = sch.dump(data) + assert "foo" in result + assert "bar" not in result + + +def test_invalid_only_and_exclude_with_additional(): + class MySchema(Schema): + foo = fields.Field() + + class Meta: + additional = ("bar", "baz") + + with pytest.raises(ValueError) as excinfo: + MySchema(only=("foop", "par"), exclude=("ban",)) + + assert "foop" in str(excinfo.value) + assert "par" in str(excinfo.value) + assert "ban" in str(excinfo.value) + + +def test_exclude_invalid_attribute(): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(ValueError, match="'bar'"): + MySchema(exclude=("bar",)) + + +def test_only_bounded_by_fields(): + class MySchema(Schema): + class Meta: + fields = ("foo",) + + with pytest.raises(ValueError, match="'baz'"): + MySchema(only=("baz",)) + + +def test_only_bounded_by_additional(): + class MySchema(Schema): + class Meta: + additional = ("b",) + + with pytest.raises(ValueError): + MySchema(only=("c",)).dump({"c": 3}) + + +def test_only_empty(): + class MySchema(Schema): + foo = fields.Field() + + sch = MySchema(only=()) + assert "foo" not in sch.dump({"foo": "bar"}) + + +@pytest.mark.parametrize("param", ("only", "exclude")) +def test_only_and_exclude_as_string(param): + class MySchema(Schema): + foo = fields.Field() + + with pytest.raises(StringNotCollectionError): + MySchema(**{param: "foo"}) + + +def test_nested_with_sets(): + class Inner(Schema): + foo = fields.Field() + + class Outer(Schema): + inners = fields.Nested(Inner, many=True) + + sch = Outer() + + DataClass = namedtuple("DataClass", ["foo"]) + data = dict(inners={DataClass(42), DataClass(2)}) + result = sch.dump(data) + assert len(result["inners"]) == 2 + + +def test_meta_serializer_fields(): + u = User("John", age=42.3, email="john@example.com", homepage="http://john.com") + result = UserMetaSchema().dump(u) + assert result["name"] == u.name + assert result["balance"] == decimal.Decimal("100.00") + assert result["uppername"] == "JOHN" + assert result["is_old"] is False + assert result["created"] == utils.isoformat(u.created) + assert result["finger_count"] == 10 + assert result["various_data"] == dict(u.various_data) + + +def test_meta_fields_mapping(user): + s = UserMetaSchema() + s.dump(user) # need to call dump to update fields + assert type(s.fields["balance"]) is fields.Decimal + # Inferred fields + assert type(s.fields["name"]._field_cache[fields.String]) is fields.String + assert type(s.fields["created"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["updated"]._field_cache[fields.DateTime]) is fields.DateTime + assert type(s.fields["age"]._field_cache[fields.Float]) is fields.Float + assert type(s.fields["registered"]._field_cache[fields.Boolean]) is fields.Boolean + assert type(s.fields["sex_choices"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["hair_colors"]._field_cache[fields.Raw]) is fields.Raw + assert type(s.fields["finger_count"]._field_cache[fields.Integer]) is fields.Integer + assert type(s.fields["uid"]._field_cache[fields.UUID]) is fields.UUID + assert type(s.fields["time_registered"]._field_cache[fields.Time]) is fields.Time + assert type(s.fields["birthdate"]._field_cache[fields.Date]) is fields.Date + assert ( + type(s.fields["since_created"]._field_cache[fields.TimeDelta]) + is fields.TimeDelta + ) + + +def test_meta_field_not_on_obj_raises_attribute_error(user): + class BadUserSchema(Schema): + class Meta: + fields = ("name",) + exclude = ("notfound",) + + with pytest.raises(ValueError, match="'notfound'"): + BadUserSchema().dump(user) + + +def test_exclude_fields(user): + s = UserExcludeSchema().dump(user) + assert "created" not in s + assert "updated" not in s + assert "name" in s + + +def test_fields_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadFields(Schema): + class Meta: + fields = "name" + + +def test_exclude_option_must_be_list_or_tuple(): + with pytest.raises(ValueError): + + class BadExclude(Schema): + class Meta: + exclude = "name" + + +def test_datetimeformat_option(user): + meta_fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateTimeFormatSchema(Schema): + updated = fields.DateTime(field_fmt) + + class Meta: + fields = ("created", "updated") + datetimeformat = meta_fmt + + serialized = DateTimeFormatSchema().dump(user) + assert serialized["created"] == user.created.strftime(meta_fmt) + assert serialized["updated"] == user.updated.strftime(field_fmt) + + +def test_dateformat_option(user): + fmt = "%Y-%m" + field_fmt = "%m-%d" + + class DateFormatSchema(Schema): + birthdate = fields.Date(field_fmt) + + class Meta: + fields = ("birthdate", "activation_date") + dateformat = fmt + + serialized = DateFormatSchema().dump(user) + assert serialized["birthdate"] == user.birthdate.strftime(field_fmt) + assert serialized["activation_date"] == user.activation_date.strftime(fmt) + + +def test_timeformat_option(user): + fmt = "%H:%M:%S" + field_fmt = "%H:%M" + + class TimeFormatSchema(Schema): + birthtime = fields.Time(field_fmt) + + class Meta: + fields = ("birthtime", "time_registered") + timeformat = fmt + + serialized = TimeFormatSchema().dump(user) + assert serialized["birthtime"] == user.birthtime.strftime(field_fmt) + assert serialized["time_registered"] == user.time_registered.strftime(fmt) + + +def test_default_dateformat(user): + class DateFormatSchema(Schema): + updated = fields.DateTime(format="%m-%d") + + class Meta: + fields = ("created", "updated") + + serialized = DateFormatSchema().dump(user) + assert serialized["created"] == utils.isoformat(user.created) + assert serialized["updated"] == user.updated.strftime("%m-%d") + + +def test_inherit_meta(user): + class InheritedMetaSchema(UserMetaSchema): + pass + + result = InheritedMetaSchema().dump(user) + expected = UserMetaSchema().dump(user) + assert result == expected + + +def test_inherit_meta_override(): + class Parent(Schema): + class Meta: + fields = ("name", "email") + dump_only = ("name",) + + class Child(Schema): + class Meta(Parent.Meta): + dump_only = ("name", "email") + + child = Child() + assert child.opts.fields == ("name", "email") + assert child.opts.dump_only == ("name", "email") + + +def test_additional(user): + s = UserAdditionalSchema().dump(user) + assert s["lowername"] == user.name.lower() + assert s["name"] == user.name + + +def test_cant_set_both_additional_and_fields(user): + with pytest.raises(ValueError): + + class BadSchema(Schema): + name = fields.String() + + class Meta: + fields = ("name", "email") + additional = ("email", "homepage") + + +def test_serializing_none_meta(): + s = UserMetaSchema().dump(None) + assert s == {} + + +class CustomError(Exception): + pass + + +class MySchema(Schema): + name = fields.String() + email = fields.Email() + age = fields.Integer() + + def handle_error(self, errors, obj, **kwargs): + raise CustomError("Something bad happened") + + def test_load_with_custom_error_handler(self): + in_data = {"email": "invalid"} + + class MySchema3(Schema): + email = fields.Email() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema3().load(in_data) + + def test_load_with_custom_error_handler_and_partially_valid_data(self): + in_data = {"email": "invalid", "url": "http://valid.com"} + + class MySchema(Schema): + email = fields.Email() + url = fields.URL() + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "email" in error.messages + assert list(error.messages.keys()) == ["email"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates("num") + def validate_num(self, value): + if value < 0: + raise ValidationError("Must be greater than 0.") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert "num" in error.messages + assert list(error.messages.keys()) == ["num"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_custom_error_handler_with_validates_schema_decorator(self): + in_data = {"num": -1} + + class MySchema(Schema): + num = fields.Int() + + @validates_schema + def validates_schema(self, data, **kwargs): + raise ValidationError("Invalid schema!") + + def handle_error(self, error, data, **kwargs): + assert type(error) is ValidationError + assert list(error.messages.keys()) == ["_schema"] + assert data == in_data + raise CustomError("Something bad happened") + + with pytest.raises(CustomError): + MySchema().load(in_data) + + def test_validate_with_custom_error_handler(self): + with pytest.raises(CustomError): + MySchema().validate({"age": "notvalid", "email": "invalid"}) + + +class TestFieldValidation: + def test_errors_are_cleared_after_loading_collection(self): + def always_fail(val): + raise ValidationError("lol") + + class MySchema(Schema): + foo = fields.Str(validate=always_fail) + + schema = MySchema() + with pytest.raises(ValidationError) as excinfo: + schema.load([{"foo": "bar"}, {"foo": "baz"}], many=True) + errors = excinfo.value.messages + assert len(errors[0]["foo"]) == 1 + assert len(errors[1]["foo"]) == 1 + with pytest.raises(ValidationError) as excinfo: + schema.load({"foo": "bar"}) + errors = excinfo.value.messages + assert len(errors["foo"]) == 1 + + def test_raises_error_with_list(self): + def validator(val): + raise ValidationError(["err1", "err2"]) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == ["err1", "err2"] + + # https://github.com/marshmallow-code/marshmallow/issues/110 + def test_raises_error_with_dict(self): + def validator(val): + raise ValidationError({"code": "invalid_foo"}) + + class MySchema(Schema): + foo = fields.Field(validate=validator) + + s = MySchema() + errors = s.validate({"foo": 42}) + assert errors["foo"] == [{"code": "invalid_foo"}] + + def test_ignored_if_not_in_only(self): + class MySchema(Schema): + a = fields.Field() + b = fields.Field() + + @validates("a") + def validate_a(self, val): + raise ValidationError({"code": "invalid_a"}) + + @validates("b") + def validate_b(self, val): + raise ValidationError({"code": "invalid_b"}) + + s = MySchema(only=("b",)) + errors = s.validate({"b": "data"}) + assert errors == {"b": {"code": "invalid_b"}} + + +def test_schema_repr(): + class MySchema(Schema): + name = fields.String() + + ser = MySchema(many=True) + rep = repr(ser) + assert "MySchema" in rep + assert "many=True" in rep + + +class TestNestedSchema: + @pytest.fixture + def user(self): + return User(name="Monty", age=81) + + @pytest.fixture + def blog(self, user): + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog( + "Monty's blog", + user=user, + categories=["humor", "violence"], + collaborators=[col1, col2], + ) + return blog + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/64 + def test_nested_many_with_missing_attribute(self, user): + class SimpleBlogSchema(Schema): + title = fields.Str() + wat = fields.Nested(UserSchema, many=True) + + blog = Blog("Simple blog", user=user, collaborators=None) + schema = SimpleBlogSchema() + result = schema.dump(blog) + assert "wat" not in result + + def test_nested_with_attribute_none(self): + class InnerSchema(Schema): + bar = fields.Field() + + class MySchema(Schema): + foo = fields.Nested(InnerSchema) + + class MySchema2(Schema): + foo = fields.Nested(InnerSchema) + + s = MySchema() + result = s.dump({"foo": None}) + assert result["foo"] is None + + s2 = MySchema2() + result2 = s2.dump({"foo": None}) + assert result2["foo"] is None + + def test_nested_field_does_not_validate_required(self): + class BlogRequiredSchema(Schema): + user = fields.Nested(UserSchema, required=True) + + b = Blog("Authorless blog", user=None) + BlogRequiredSchema().dump(b) + + def test_nested_none(self): + class BlogDefaultSchema(Schema): + user = fields.Nested(UserSchema, dump_default=0) + + b = Blog("Just the default blog", user=None) + data = BlogDefaultSchema().dump(b) + assert data["user"] is None + + def test_nested(self, user, blog): + blog_serializer = BlogSchema() + serialized_blog = blog_serializer.dump(blog) + user_serializer = UserSchema() + serialized_user = user_serializer.dump(user) + assert serialized_blog["user"] == serialized_user + + with pytest.raises(ValidationError, match="email"): + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + + def test_nested_many_fields(self, blog): + serialized_blog = BlogSchema().dump(blog) + expected = [UserSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_meta_many(self, blog): + serialized_blog = BlogUserMetaSchema().dump(blog) + assert len(serialized_blog["collaborators"]) == 2 + expected = [UserMetaSchema().dump(col) for col in blog.collaborators] + assert serialized_blog["collaborators"] == expected + + def test_nested_only(self, blog): + col1 = User(name="Mick", age=123, id_="abc") + col2 = User(name="Keith", age=456, id_="def") + blog.collaborators = [col1, col2] + serialized_blog = BlogOnlySchema().dump(blog) + assert serialized_blog["collaborators"] == [{"id": col1.id}, {"id": col2.id}] + + def test_exclude(self, blog): + serialized = BlogSchemaExclude().dump(blog) + assert "uppername" not in serialized["user"].keys() + + def test_list_field(self, blog): + serialized = BlogSchema().dump(blog) + assert serialized["categories"] == ["humor", "violence"] + + def test_nested_load_many(self): + in_data = { + "title": "Shine A Light", + "collaborators": [ + {"name": "Mick", "email": "mick@stones.com"}, + {"name": "Keith", "email": "keith@stones.com"}, + ], + } + data = BlogSchema().load(in_data) + collabs = data["collaborators"] + assert len(collabs) == 2 + assert all(type(each) is User for each in collabs) + assert collabs[0].name == in_data["collaborators"][0]["name"] + + def test_nested_errors(self): + with pytest.raises(ValidationError) as excinfo: + BlogSchema().load( + {"title": "Monty's blog", "user": {"name": "Monty", "email": "foo"}} + ) + errors = excinfo.value.messages + assert "email" in errors["user"] + assert len(errors["user"]["email"]) == 1 + assert "Not a valid email address." in errors["user"]["email"][0] + # No problems with collaborators + assert "collaborators" not in errors + + def test_nested_method_field(self, blog): + data = BlogSchema().dump(blog) + assert data["user"]["is_old"] + assert data["collaborators"][0]["is_old"] + + def test_nested_function_field(self, blog, user): + data = BlogSchema().dump(blog) + assert data["user"]["lowername"] == user.name.lower() + expected = blog.collaborators[0].name.lower() + assert data["collaborators"][0]["lowername"] == expected + + def test_serializer_meta_with_nested_fields(self, blog, user): + data = BlogSchemaMeta().dump(blog) + assert data["title"] == blog.title + assert data["user"] == UserSchema().dump(user) + assert data["collaborators"] == [ + UserSchema().dump(c) for c in blog.collaborators + ] + assert data["categories"] == blog.categories + + def test_serializer_with_nested_meta_fields(self, blog): + # Schema has user = fields.Nested(UserMetaSerializer) + s = BlogUserMetaSchema().dump(blog) + assert s["user"] == UserMetaSchema().dump(blog.user) + + def test_nested_fields_must_be_passed_a_serializer(self, blog): + class BadNestedFieldSchema(BlogSchema): + user = fields.Nested(fields.String) + + with pytest.raises(ValueError): + BadNestedFieldSchema().dump(blog) + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/188 + def test_invalid_type_passed_to_nested_field(self): + class InnerSchema(Schema): + foo = fields.Field() + + class MySchema(Schema): + inner = fields.Nested(InnerSchema, many=True) + + sch = MySchema() + + sch.load({"inner": [{"foo": 42}]}) + + with pytest.raises(ValidationError) as excinfo: + sch.load({"inner": "invalid"}) + errors = excinfo.value.messages + assert "inner" in errors + assert errors["inner"] == ["Invalid type."] + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema) + + schema = OuterSchema() + with pytest.raises(ValidationError) as excinfo: + schema.load({"inner": 1}) + errors = excinfo.value.messages + assert errors["inner"]["_schema"] == ["Invalid input type."] + + # regression test for https://github.com/marshmallow-code/marshmallow/issues/298 + def test_all_errors_on_many_nested_field_with_validates_decorator(self): + class Inner(Schema): + req = fields.Field(required=True) + + class Outer(Schema): + inner = fields.Nested(Inner, many=True) + + @validates("inner") + def validates_inner(self, data): + raise ValidationError("not a chance") + + outer = Outer() + with pytest.raises(ValidationError) as excinfo: + outer.load({"inner": [{}]}) + errors = excinfo.value.messages + assert "inner" in errors + assert "_schema" in errors["inner"] + + @pytest.mark.parametrize("unknown", (None, RAISE, INCLUDE, EXCLUDE)) + def test_nested_unknown_validation(self, unknown): + class ChildSchema(Schema): + num = fields.Int() + + class ParentSchema(Schema): + child = fields.Nested(ChildSchema, unknown=unknown) + + data = {"child": {"num": 1, "extra": 1}} + if unknown is None or unknown == RAISE: + with pytest.raises(ValidationError) as exc: + ParentSchema().load(data) + assert exc.messages == {"child": {"extra": ["Unknown field."]}} + else: + output = { + INCLUDE: {"child": {"num": 1, "extra": 1}}, + EXCLUDE: {"child": {"num": 1}}, + }[unknown] + assert ParentSchema().load(data) == output + + +class TestPluckSchema: + @pytest.mark.parametrize("user_schema", [UserSchema, UserSchema()]) + def test_pluck(self, user_schema, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(user_schema, "name") + collaborators = fields.Pluck(user_schema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + def test_pluck_none(self, blog): + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + col1 = User(name="Mick", age=123) + col2 = User(name="Keith", age=456) + blog = Blog(title="Unowned Blog", user=None, collaborators=[col1, col2]) + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/800 + def test_pluck_with_data_key(self, blog): + class UserSchema(Schema): + name = fields.String(data_key="username") + age = fields.Int() + + class FlatBlogSchema(Schema): + user = fields.Pluck(UserSchema, "name") + collaborators = fields.Pluck(UserSchema, "name", many=True) + + s = FlatBlogSchema() + data = s.dump(blog) + assert data["user"] == blog.user.name + for i, name in enumerate(data["collaborators"]): + assert name == blog.collaborators[i].name + assert s.load(data) == { + "user": {"name": "Monty"}, + "collaborators": [{"name": "Mick"}, {"name": "Keith"}], + } + + +class TestSelfReference: + @pytest.fixture + def employer(self): + return User(name="Joe", age=59) + + @pytest.fixture + def user(self, employer): + return User(name="Tom", employer=employer, age=28) + + def test_nesting_schema_by_passing_lambda(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested( + lambda: SelfReferencingSchema(exclude=("employer",)) + ) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_by_passing_class_name(self, user, employer): + class SelfReferencingSchema(Schema): + name = fields.Str() + age = fields.Int() + employer = fields.Nested("SelfReferencingSchema", exclude=("employer",)) + + data = SelfReferencingSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_schema_self_string(self, user, employer): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfSchema(Schema): + name = fields.String() + age = fields.Integer() + employer = fields.Nested("self", exclude=("employer",)) + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nesting_within_itself_meta(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(exclude=("employer",))) + + class Meta: + additional = ("name", "age") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["age"] == user.age + assert data["employer"]["name"] == employer.name + assert data["employer"]["age"] == employer.age + + def test_nested_self_with_only_param(self, user, employer): + class SelfSchema(Schema): + employer = fields.Nested(lambda: SelfSchema(only=("name",))) + + class Meta: + fields = ("name", "employer") + + data = SelfSchema().dump(user) + assert data["name"] == user.name + assert data["employer"]["name"] == employer.name + assert "age" not in data["employer"] + + def test_multiple_pluck_self_lambda(self, user): + class MultipleSelfSchema(Schema): + emp = fields.Pluck( + lambda: MultipleSelfSchema(), "name", attribute="employer" + ) + rels = fields.Pluck( + lambda: MultipleSelfSchema(), "name", many=True, attribute="relatives" + ) + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_multiple_pluck_self_string(self, user): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class MultipleSelfSchema(Schema): + emp = fields.Pluck("self", "name", attribute="employer") + rels = fields.Pluck("self", "name", many=True, attribute="relatives") + + class Meta: + fields = ("name", "emp", "rels") + + schema = MultipleSelfSchema() + user.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = schema.dump(user) + assert len(data["rels"]) == len(user.relatives) + relative = data["rels"][0] + assert relative == user.relatives[0].name + + def test_nested_self_many_lambda(self): + class SelfManySchema(Schema): + relatives = fields.Nested(lambda: SelfManySchema(), many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_many_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfManySchema(Schema): + relatives = fields.Nested("self", many=True) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfManySchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list(self): + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested(lambda: SelfListSchema())) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + def test_nested_self_list_string(self): + with pytest.warns( + DeprecationWarning, match="Passing 'self' to `Nested` is deprecated" + ): + + class SelfListSchema(Schema): + relatives = fields.List(fields.Nested("self")) + + class Meta: + additional = ("name", "age") + + person = User(name="Foo") + person.relatives = [User(name="Bar", age=12), User(name="Baz", age=34)] + data = SelfListSchema().dump(person) + assert data["name"] == person.name + assert len(data["relatives"]) == len(person.relatives) + assert data["relatives"][0]["name"] == person.relatives[0].name + assert data["relatives"][0]["age"] == person.relatives[0].age + + +class RequiredUserSchema(Schema): + name = fields.Field(required=True) + + +def test_serialization_with_required_field(): + user = User(name=None) + RequiredUserSchema().dump(user) + + +def test_deserialization_with_required_field(): + in_data = {} + with pytest.raises(ValidationError) as excinfo: + RequiredUserSchema().load(in_data) + data, errors = excinfo.value.valid_data, excinfo.value.messages + assert "name" in errors + assert "Missing data for required field." in errors["name"] + # field value should also not be in output data + assert "name" not in data + + +def test_deserialization_with_required_field_and_custom_validator(): + class ValidatingSchema(Schema): + color = fields.String( + required=True, + validate=lambda x: x.lower() == "red" or x.lower() == "blue", + error_messages={"validator_failed": "Color must be red or blue"}, + ) + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"name": "foo"}) + errors = excinfo.value.messages + assert errors + assert "color" in errors + assert "Missing data for required field." in errors["color"] + + with pytest.raises(ValidationError) as excinfo: + ValidatingSchema().load({"color": "green"}) + errors = excinfo.value.messages + assert "color" in errors + assert "Color must be red or blue" in errors["color"] + + +class UserContextSchema(Schema): + is_owner = fields.Method("get_is_owner") + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + def get_is_owner(self, user): + return self.context["blog"].user.name == user.name + + +class TestContext: + def test_context_method(self): + owner = User("Joe") + blog = Blog(title="Joe Blog", user=owner) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(owner) + assert data["is_owner"] is True + nonowner = User("Fred") + data = serializer.dump(nonowner) + assert data["is_owner"] is False + + def test_context_method_function(self): + owner = User("Fred") + blog = Blog("Killer Queen", user=owner) + collab = User("Brian") + blog.collaborators.append(collab) + context = {"blog": blog} + serializer = UserContextSchema() + serializer.context = context + data = serializer.dump(collab) + assert data["is_collab"] is True + noncollab = User("Foo") + data = serializer.dump(noncollab) + assert data["is_collab"] is False + + def test_function_field_raises_error_when_context_not_available(self): + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(lambda user, ctx: user in ctx["blog"]) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + msg = "No context available for Function field {!r}".format("is_collab") + with pytest.raises(ValidationError, match=msg): + serializer.dump(owner) + + def test_function_field_handles_bound_serializer(self): + class SerializeA: + def __call__(self, value): + return "value" + + serialize = SerializeA() + + # only has a function field + class UserFunctionContextSchema(Schema): + is_collab = fields.Function(serialize) + + owner = User("Joe") + serializer = UserFunctionContextSchema() + # no context + serializer.context = None + data = serializer.dump(owner) + assert data["is_collab"] == "value" + + def test_fields_context(self): + class CSchema(Schema): + name = fields.String() + + ser = CSchema() + ser.context["foo"] = 42 + + assert ser.fields["name"].context == {"foo": 42} + + def test_nested_fields_inherit_context(self): + class InnerSchema(Schema): + likes_bikes = fields.Function(lambda obj, ctx: "bikes" in ctx["info"]) + + class CSchema(Schema): + inner = fields.Nested(InnerSchema) + + ser = CSchema() + ser.context["info"] = "i like bikes" + obj = {"inner": {}} + result = ser.dump(obj) + assert result["inner"]["likes_bikes"] is True + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_list_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.List(fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": [{"foo": 42}]}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/820 + def test_nested_dict_fields_inherit_context(self): + class InnerSchema(Schema): + foo = fields.Field() + + @validates("foo") + def validate_foo(self, value): + if "foo_context" not in self.context: + raise ValidationError("Missing context") + + class OuterSchema(Schema): + bars = fields.Dict(values=fields.Nested(InnerSchema())) + + inner = InnerSchema() + inner.context["foo_context"] = "foo" + assert inner.load({"foo": 42}) + + outer = OuterSchema() + outer.context["foo_context"] = "foo" + assert outer.load({"bars": {"test": {"foo": 42}}}) + + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1404 + def test_nested_field_with_unpicklable_object_in_context(self): + class Unpicklable: + def __deepcopy__(self, _): + raise NotImplementedError + + class InnerSchema(Schema): + foo = fields.Field() + + class OuterSchema(Schema): + inner = fields.Nested(InnerSchema(context={"unp": Unpicklable()})) + + outer = OuterSchema() + obj = {"inner": {"foo": 42}} + assert outer.dump(obj) + + +def test_serializer_can_specify_nested_object_as_attribute(blog): + class BlogUsernameSchema(Schema): + author_name = fields.String(attribute="user.name") + + ser = BlogUsernameSchema() + result = ser.dump(blog) + assert result["author_name"] == blog.user.name + + +class TestFieldInheritance: + def test_inherit_fields_from_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + assert SerializerB._declared_fields == expected + + def test_inherit_fields_from_non_schema_subclass(self): + expected = { + "field_a": fields.Number(), + "field_b": fields.Number(), + } + + class PlainBaseClass: + field_a = expected["field_a"] + + class SerializerB1(Schema, PlainBaseClass): + field_b = expected["field_b"] + + class SerializerB2(PlainBaseClass, Schema): + field_b = expected["field_b"] + + assert SerializerB1._declared_fields == expected + assert SerializerB2._declared_fields == expected + + def test_inheritance_follows_mro(self): + expected = { + "field_a": fields.String(), + "field_b": fields.String(), + "field_c": fields.String(), + "field_d": fields.String(), + } + # Diamond inheritance graph + # MRO: D -> B -> C -> A + + class SerializerA(Schema): + field_a = expected["field_a"] + + class SerializerB(SerializerA): + field_b = expected["field_b"] + + class SerializerC(SerializerA): + field_c = expected["field_c"] + + class SerializerD(SerializerB, SerializerC): + field_d = expected["field_d"] + + assert SerializerD._declared_fields == expected + + +def get_from_dict(schema, obj, key, default=None): + return obj.get("_" + key, default) + + +class TestGetAttribute: + def test_get_attribute_is_used(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dict = {"_name": "joe", "_email": "joe@shmoe.com"} + schema = UserDictSchema() + result = schema.dump(user_dict) + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + user = User(name="joe", email="joe@shmoe.com") + with pytest.raises(AttributeError): + schema.dump(user) + + def test_get_attribute_with_many(self): + class UserDictSchema(Schema): + name = fields.Str() + email = fields.Email() + + def get_attribute(self, obj, attr, default): + return get_from_dict(self, obj, attr, default) + + user_dicts = [ + {"_name": "joe", "_email": "joe@shmoe.com"}, + {"_name": "jane", "_email": "jane@shmane.com"}, + ] + schema = UserDictSchema(many=True) + results = schema.dump(user_dicts) + for result, user_dict in zip(results, user_dicts): + assert result["name"] == user_dict["_name"] + assert result["email"] == user_dict["_email"] + # can't serialize User object + users = [ + User(name="joe", email="joe@shmoe.com"), + User(name="jane", email="jane@shmane.com"), + ] + with pytest.raises(AttributeError): + schema.dump(users) + + +class TestRequiredFields: + class StringSchema(Schema): + required_field = fields.Str(required=True) + allow_none_field = fields.Str(allow_none=True) + allow_none_required_field = fields.Str(required=True, allow_none=True) + + @pytest.fixture() + def string_schema(self): + return self.StringSchema() + + @pytest.fixture() + def data(self): + return dict( + required_field="foo", + allow_none_field="bar", + allow_none_required_field="one", + ) + + def test_required_string_field_missing(self, string_schema, data): + del data["required_field"] + errors = string_schema.validate(data) + assert errors["required_field"] == ["Missing data for required field."] + + def test_required_string_field_failure(self, string_schema, data): + data["required_field"] = None + errors = string_schema.validate(data) + assert errors["required_field"] == ["Field may not be null."] + + def test_allow_none_param(self, string_schema, data): + data["allow_none_field"] = None + errors = string_schema.validate(data) + assert errors == {} + + data["allow_none_required_field"] = None + string_schema.validate(data) + + del data["allow_none_required_field"] + errors = string_schema.validate(data) + assert "allow_none_required_field" in errors + + def test_allow_none_custom_message(self, data): + class MySchema(Schema): + allow_none_field = fields.Field( + allow_none=False, error_messages={"null": ""} + ) + + schema = MySchema() + errors = schema.validate({"allow_none_field": None}) + assert errors["allow_none_field"][0] == "" + + +class TestDefaults: + class MySchema(Schema): + int_no_default = fields.Int(allow_none=True) + str_no_default = fields.Str(allow_none=True) + list_no_default = fields.List(fields.Str, allow_none=True) + nested_no_default = fields.Nested(UserSchema, many=True, allow_none=True) + + int_with_default = fields.Int(allow_none=True, dump_default=42) + str_with_default = fields.Str(allow_none=True, dump_default="foo") + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + int_no_default=None, + str_no_default=None, + list_no_default=None, + nested_no_default=None, + int_with_default=None, + str_with_default=None, + ) + + def test_missing_inputs_are_excluded_from_dump_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.dump(d) + # the missing key is not in the serialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + def test_none_is_serialized_to_none(self, schema, data): + errors = schema.validate(data) + assert errors == {} + result = schema.dump(data) + for key in data.keys(): + msg = f"result[{key!r}] should be None" + assert result[key] is None, msg + + def test_default_and_value_missing(self, schema, data): + del data["int_with_default"] + del data["str_with_default"] + result = schema.dump(data) + assert result["int_with_default"] == 42 + assert result["str_with_default"] == "foo" + + def test_loading_none(self, schema, data): + result = schema.load(data) + for key in data.keys(): + assert result[key] is None + + def test_missing_inputs_are_excluded_from_load_output(self, schema, data): + for key in [ + "int_no_default", + "str_no_default", + "list_no_default", + "nested_no_default", + ]: + d = data.copy() + del d[key] + result = schema.load(d) + # the missing key is not in the deserialized result + assert key not in result + # the rest of the keys are in the result + assert all(k in result for k in d.keys()) + + +class TestLoadOnly: + class MySchema(Schema): + class Meta: + load_only = ("str_load_only",) + dump_only = ("str_dump_only",) + + str_dump_only = fields.String() + str_load_only = fields.String() + str_regular = fields.String() + + @pytest.fixture() + def schema(self): + return self.MySchema() + + @pytest.fixture() + def data(self): + return dict( + str_dump_only="Dump Only", + str_load_only="Load Only", + str_regular="Regular String", + ) + + def test_load_only(self, schema, data): + result = schema.dump(data) + assert "str_load_only" not in result + assert "str_dump_only" in result + assert "str_regular" in result + + def test_dump_only(self, schema, data): + result = schema.load(data, unknown=EXCLUDE) + assert "str_dump_only" not in result + assert "str_load_only" in result + assert "str_regular" in result + + # regression test for https://github.com/marshmallow-code/marshmallow/pull/765 + def test_url_field_requre_tld_false(self): + class NoTldTestSchema(Schema): + url = fields.Url(require_tld=False, schemes=["marshmallow"]) + + schema = NoTldTestSchema() + data_with_no_top_level_domain = {"url": "marshmallow://app/discounts"} + result = schema.load(data_with_no_top_level_domain) + assert result == data_with_no_top_level_domain + + +class TestFromDict: + def test_generates_schema(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert issubclass(MySchema, Schema) + + def test_name(self): + MySchema = Schema.from_dict({"foo": fields.Str()}) + assert "GeneratedSchema" in repr(MySchema) + SchemaWithName = Schema.from_dict( + {"foo": fields.Int()}, name="MyGeneratedSchema" + ) + assert "MyGeneratedSchema" in repr(SchemaWithName) + + def test_generated_schemas_are_not_registered(self): + n_registry_entries = len(class_registry._registry) + Schema.from_dict({"foo": fields.Str()}) + Schema.from_dict({"bar": fields.Str()}, name="MyGeneratedSchema") + assert len(class_registry._registry) == n_registry_entries + with pytest.raises(RegistryError): + class_registry.get_class("GeneratedSchema") + with pytest.raises(RegistryError): + class_registry.get_class("MyGeneratedSchema") + + def test_meta_options_are_applied(self): + class OrderedSchema(Schema): + class Meta: + ordered = True + load_only = ("bar",) + + OSchema = OrderedSchema.from_dict({"foo": fields.Int(), "bar": fields.Int()}) + dumped = OSchema().dump({"foo": 42, "bar": 24}) + assert isinstance(dumped, OrderedDict) + assert "bar" not in dumped + + +def test_class_registry_returns_schema_type(): + class DefinitelyUniqueSchema(Schema): + """ + Just a schema + """ + + SchemaClass = class_registry.get_class(DefinitelyUniqueSchema.__name__) + assert SchemaClass is DefinitelyUniqueSchema + + +@pytest.mark.parametrize("usage_location", ["meta", "init", "load"]) +def test_unknown_parameter_value_is_validated(usage_location): + class MySchema(Schema): + foo = fields.String() + + with pytest.raises( + ValueError, + match="Object 'badval' is not a valid value for the 'unknown' parameter", + ): + # Meta.unknown setting gets caught at class creation time, since that's when + # metaclass __new__ runs + if usage_location == "meta": + + class SubSchema(MySchema): + class Meta: + unknown = "badval" + + # usages in init and load are caught at call time, as expected + elif usage_location == "init": + MySchema(unknown="badval") + else: + MySchema().load({"foo": "bar"}, unknown="badval") + + +@pytest.mark.parametrize("dict_cls", (dict, OrderedDict)) +def test_set_dict_class(dict_cls): + """Demonstrate how to specify dict_class as class attribute""" + + class MySchema(Schema): + dict_class = dict_cls + foo = fields.String() + + result = MySchema().dump({"foo": "bar"}) + assert result == {"foo": "bar"} + assert isinstance(result, dict_cls) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_serialization.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_serialization.py new file mode 100644 index 0000000000000000000000000000000000000000..df778ce82e570540b011ce4e1013f3da5a2000c2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_serialization.py @@ -0,0 +1,1041 @@ +"""Tests for field serialization.""" + +import datetime as dt +import decimal +import ipaddress +import itertools +import math +import uuid +from collections import OrderedDict, namedtuple + +import pytest + +from marshmallow import Schema, fields +from marshmallow import missing as missing_ +from tests.base import ALL_FIELDS, DateEnum, GenderEnum, HairColorEnum, User, central + + +class DateTimeList: + def __init__(self, dtimes): + self.dtimes = dtimes + + +class IntegerList: + def __init__(self, ints): + self.ints = ints + + +class DateTimeIntegerTuple: + def __init__(self, dtime_int): + self.dtime_int = dtime_int + + +class TestFieldSerialization: + @pytest.fixture + def user(self): + return User("Foo", email="foo@bar.com", age=42) + + @pytest.mark.parametrize( + ("value", "expected"), [(42, float(42)), (0, float(0)), (None, None)] + ) + def test_number(self, value, expected, user): + field = fields.Number() + user.age = value + assert field.serialize("age", user) == expected + + def test_number_as_string(self, user): + user.age = 42 + field = fields.Number(as_string=True) + assert field.serialize("age", user) == str(float(user.age)) + + def test_number_as_string_passed_none(self, user): + user.age = None + field = fields.Number(as_string=True, allow_none=True) + assert field.serialize("age", user) is None + + def test_function_field_passed_func(self, user): + field = fields.Function(lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + def test_function_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert field.dump_only is True + + def test_function_field_passed_deserialize_and_serialize_is_not_dump_only(self): + field = fields.Function( + serialize=lambda val: val.lower(), deserialize=lambda val: val.upper() + ) + assert field.dump_only is False + + def test_function_field_passed_serialize(self, user): + field = fields.Function(serialize=lambda obj: obj.name.upper()) + assert "FOO" == field.serialize("key", user) + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_function_field_does_not_swallow_attribute_error(self, user): + def raise_error(obj): + raise AttributeError() + + field = fields.Function(serialize=raise_error) + with pytest.raises(AttributeError): + field.serialize("key", user) + + def test_serialize_with_load_only_param(self): + class AliasingUserSerializer(Schema): + name = fields.String() + years = fields.Integer(load_only=True) + size = fields.Integer(dump_only=True, load_only=True) + nicknames = fields.List(fields.Str(), load_only=True) + + data = { + "name": "Mick", + "years": "42", + "size": "12", + "nicknames": ["Your Majesty", "Brenda"], + } + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert "years" not in result + assert "size" not in result + assert "nicknames" not in result + + def test_function_field_load_only(self): + field = fields.Function(deserialize=lambda obj: None) + assert field.load_only + + def test_function_field_passed_serialize_with_context(self, user, monkeypatch): + class Parent(Schema): + pass + + field = fields.Function( + serialize=lambda obj, context: obj.name.upper() + context["key"] + ) + field.parent = Parent(context={"key": "BAR"}) + assert "FOOBAR" == field.serialize("key", user) + + def test_function_field_passed_uncallable_object(self): + with pytest.raises(TypeError): + fields.Function("uncallable") + + def test_integer_field(self, user): + field = fields.Integer() + assert field.serialize("age", user) == 42 + + def test_integer_as_string_field(self, user): + field = fields.Integer(as_string=True) + assert field.serialize("age", user) == "42" + + def test_integer_field_default(self, user): + user.age = None + field = fields.Integer(dump_default=0) + assert field.serialize("age", user) is None + # missing + assert field.serialize("age", {}) == 0 + + def test_integer_field_default_set_to_none(self, user): + user.age = None + field = fields.Integer(dump_default=None) + assert field.serialize("age", user) is None + + def test_uuid_field(self, user): + user.uuid1 = uuid.UUID("12345678123456781234567812345678") + user.uuid2 = None + + field = fields.UUID() + assert isinstance(field.serialize("uuid1", user), str) + assert field.serialize("uuid1", user) == "12345678-1234-5678-1234-567812345678" + assert field.serialize("uuid2", user) is None + + def test_ip_address_field(self, user): + ipv4_string = "192.168.0.1" + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IP() + assert isinstance(field_compressed.serialize("ipv4", user), str) + assert field_compressed.serialize("ipv4", user) == ipv4_string + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IP(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ipv4_address_field(self, user): + ipv4_string = "192.168.0.1" + + user.ipv4 = ipaddress.ip_address(ipv4_string) + user.empty_ip = None + + field = fields.IPv4() + assert isinstance(field.serialize("ipv4", user), str) + assert field.serialize("ipv4", user) == ipv4_string + assert field.serialize("empty_ip", user) is None + + def test_ipv6_address_field(self, user): + ipv6_string = "ffff::ffff" + ipv6_exploded_string = ipaddress.ip_address("ffff::ffff").exploded + + user.ipv6 = ipaddress.ip_address(ipv6_string) + user.empty_ip = None + + field_compressed = fields.IPv6() + assert isinstance(field_compressed.serialize("ipv6", user), str) + assert field_compressed.serialize("ipv6", user) == ipv6_string + assert field_compressed.serialize("empty_ip", user) is None + + field_exploded = fields.IPv6(exploded=True) + assert isinstance(field_exploded.serialize("ipv6", user), str) + assert field_exploded.serialize("ipv6", user) == ipv6_exploded_string + + def test_ip_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPInterface() + assert isinstance(field_compressed.serialize("ipv4interface", user), str) + assert field_compressed.serialize("ipv4interface", user) == ipv4interface_string + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPInterface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_ipv4_interface_field(self, user): + ipv4interface_string = "192.168.0.1/24" + + user.ipv4interface = ipaddress.ip_interface(ipv4interface_string) + user.empty_ipinterface = None + + field = fields.IPv4Interface() + assert isinstance(field.serialize("ipv4interface", user), str) + assert field.serialize("ipv4interface", user) == ipv4interface_string + assert field.serialize("empty_ipinterface", user) is None + + def test_ipv6_interface_field(self, user): + ipv6interface_string = "ffff::ffff/128" + ipv6interface_exploded_string = ipaddress.ip_interface( + "ffff::ffff/128" + ).exploded + + user.ipv6interface = ipaddress.ip_interface(ipv6interface_string) + user.empty_ipinterface = None + + field_compressed = fields.IPv6Interface() + assert isinstance(field_compressed.serialize("ipv6interface", user), str) + assert field_compressed.serialize("ipv6interface", user) == ipv6interface_string + assert field_compressed.serialize("empty_ipinterface", user) is None + + field_exploded = fields.IPv6Interface(exploded=True) + assert isinstance(field_exploded.serialize("ipv6interface", user), str) + assert ( + field_exploded.serialize("ipv6interface", user) + == ipv6interface_exploded_string + ) + + def test_enum_field_by_symbol_serialization(self, user): + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum) + assert field.serialize("sex", user) == "male" + + def test_enum_field_by_value_true_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=True) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=True) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + + def test_enum_field_by_value_field_serialization(self, user): + user.hair_color = HairColorEnum.black + field = fields.Enum(HairColorEnum, by_value=fields.String) + assert field.serialize("hair_color", user) == "black hair" + user.sex = GenderEnum.male + field = fields.Enum(GenderEnum, by_value=fields.Integer) + assert field.serialize("sex", user) == 1 + user.some_date = DateEnum.date_1 + field = fields.Enum(DateEnum, by_value=fields.Date(format="%d/%m/%Y")) + assert field.serialize("some_date", user) == "29/02/2004" + + def test_decimal_field(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal() + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.355") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.4") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN) + assert isinstance(field.serialize("m1", user), decimal.Decimal) + assert field.serialize("m1", user) == decimal.Decimal(12) + assert isinstance(field.serialize("m2", user), decimal.Decimal) + assert field.serialize("m2", user) == decimal.Decimal("12.3") + assert isinstance(field.serialize("m3", user), decimal.Decimal) + assert field.serialize("m3", user) == decimal.Decimal(1) + assert field.serialize("m4", user) is None + + def test_decimal_field_string(self, user): + user.m1 = 12 + user.m2 = "12.355" + user.m3 = decimal.Decimal(1) + user.m4 = None + + field = fields.Decimal(as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.355" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.4" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + field = fields.Decimal(1, decimal.ROUND_DOWN, as_string=True) + assert isinstance(field.serialize("m1", user), str) + assert field.serialize("m1", user) == "12.0" + assert isinstance(field.serialize("m2", user), str) + assert field.serialize("m2", user) == "12.3" + assert isinstance(field.serialize("m3", user), str) + assert field.serialize("m3", user) == "1.0" + assert field.serialize("m4", user) is None + + def test_decimal_field_special_values(self, user): + user.m1 = "-NaN" + user.m2 = "NaN" + user.m3 = "-sNaN" + user.m4 = "sNaN" + user.m5 = "-Infinity" + user.m6 = "Infinity" + user.m7 = "-0" + + field = fields.Decimal(places=2, allow_nan=True) + + m1s = field.serialize("m1", user) + assert isinstance(m1s, decimal.Decimal) + assert m1s.is_qnan() and not m1s.is_signed() + + m2s = field.serialize("m2", user) + assert isinstance(m2s, decimal.Decimal) + assert m2s.is_qnan() and not m2s.is_signed() + + m3s = field.serialize("m3", user) + assert isinstance(m3s, decimal.Decimal) + assert m3s.is_qnan() and not m3s.is_signed() + + m4s = field.serialize("m4", user) + assert isinstance(m4s, decimal.Decimal) + assert m4s.is_qnan() and not m4s.is_signed() + + m5s = field.serialize("m5", user) + assert isinstance(m5s, decimal.Decimal) + assert m5s.is_infinite() and m5s.is_signed() + + m6s = field.serialize("m6", user) + assert isinstance(m6s, decimal.Decimal) + assert m6s.is_infinite() and not m6s.is_signed() + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + field = fields.Decimal(as_string=True, allow_nan=True) + + m2s = field.serialize("m2", user) + assert isinstance(m2s, str) + assert m2s == user.m2 + + m5s = field.serialize("m5", user) + assert isinstance(m5s, str) + assert m5s == user.m5 + + m6s = field.serialize("m6", user) + assert isinstance(m6s, str) + assert m6s == user.m6 + + def test_decimal_field_special_values_not_permitted(self, user): + user.m7 = "-0" + + field = fields.Decimal(places=2) + + m7s = field.serialize("m7", user) + assert isinstance(m7s, decimal.Decimal) + assert m7s.is_zero() and m7s.is_signed() + + def test_decimal_field_fixed_point_representation(self, user): + """ + Test we get fixed-point string representation for a Decimal number that would normally + output in engineering notation. + """ + user.m1 = "0.00000000100000000" + + field = fields.Decimal() + s = field.serialize("m1", user) + assert isinstance(s, decimal.Decimal) + assert s == decimal.Decimal("1.00000000E-9") + + field = fields.Decimal(as_string=True) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == user.m1 + + field = fields.Decimal(as_string=True, places=2) + s = field.serialize("m1", user) + assert isinstance(s, str) + assert s == "0.00" + + def test_boolean_field_serialization(self, user): + field = fields.Boolean() + + user.truthy = "non-falsy-ish" + user.falsy = "false" + user.none = None + + assert field.serialize("truthy", user) is True + assert field.serialize("falsy", user) is False + assert field.serialize("none", user) is None + + def test_email_field_serialize_none(self, user): + user.email = None + field = fields.Email() + assert field.serialize("email", user) is None + + def test_dict_field_serialize_none(self, user): + user.various_data = None + field = fields.Dict() + assert field.serialize("various_data", user) is None + + def test_dict_field_serialize(self, user): + user.various_data = {"foo": "bar"} + field = fields.Dict() + dump = field.serialize("various_data", user) + assert dump == {"foo": "bar"} + # Check dump is a distinct object + dump["foo"] = "baz" + assert user.various_data["foo"] == "bar" + + def test_dict_field_serialize_ordereddict(self, user): + user.various_data = OrderedDict([("foo", "bar"), ("bar", "baz")]) + field = fields.Dict() + assert field.serialize("various_data", user) == OrderedDict( + [("foo", "bar"), ("bar", "baz")] + ) + + def test_structured_dict_value_serialize(self, user): + user.various_data = {"foo": decimal.Decimal("1")} + field = fields.Dict(values=fields.Decimal) + assert field.serialize("various_data", user) == {"foo": 1} + + def test_structured_dict_key_serialize(self, user): + user.various_data = {1: "bar"} + field = fields.Dict(keys=fields.Str) + assert field.serialize("various_data", user) == {"1": "bar"} + + def test_structured_dict_key_value_serialize(self, user): + user.various_data = {1: decimal.Decimal("1")} + field = fields.Dict(keys=fields.Str, values=fields.Decimal) + assert field.serialize("various_data", user) == {"1": 1} + + def test_url_field_serialize_none(self, user): + user.homepage = None + field = fields.Url() + assert field.serialize("homepage", user) is None + + def test_method_field_with_method_missing(self): + class BadSerializer(Schema): + bad_field = fields.Method("invalid") + + with pytest.raises(AttributeError): + BadSerializer() + + def test_method_field_passed_serialize_only_is_dump_only(self, user): + field = fields.Method(serialize="method") + assert field.dump_only is True + assert field.load_only is False + + def test_method_field_passed_deserialize_only_is_load_only(self): + field = fields.Method(deserialize="somemethod") + assert field.load_only is True + assert field.dump_only is False + + def test_method_field_with_uncallable_attribute(self): + class BadSerializer(Schema): + foo = "not callable" + bad_field = fields.Method("foo") + + with pytest.raises(TypeError): + BadSerializer() + + # https://github.com/marshmallow-code/marshmallow/issues/395 + def test_method_field_does_not_swallow_attribute_error(self): + class MySchema(Schema): + mfield = fields.Method("raise_error") + + def raise_error(self, obj): + raise AttributeError() + + with pytest.raises(AttributeError): + MySchema().dump({}) + + def test_method_with_no_serialize_is_missing(self): + m = fields.Method() + m.parent = Schema() + + assert m.serialize("", "", "") is missing_ + + def test_serialize_with_data_key_param(self): + class DumpToSchema(Schema): + name = fields.String(data_key="NamE") + years = fields.Integer(data_key="YearS") + + data = {"name": "Richard", "years": 11} + result = DumpToSchema().dump(data) + assert result == {"NamE": "Richard", "YearS": 11} + + def test_serialize_with_data_key_as_empty_string(self): + class MySchema(Schema): + name = fields.Field(data_key="") + + schema = MySchema() + assert schema.dump({"name": "Grace"}) == {"": "Grace"} + + def test_serialize_with_attribute_and_data_key_uses_data_key(self): + class ConfusedDumpToAndAttributeSerializer(Schema): + name = fields.String(data_key="FullName") + username = fields.String(attribute="uname", data_key="UserName") + years = fields.Integer(attribute="le_wild_age", data_key="Years") + + data = {"name": "Mick", "uname": "mick_the_awesome", "le_wild_age": 999} + result = ConfusedDumpToAndAttributeSerializer().dump(data) + + assert result == { + "FullName": "Mick", + "UserName": "mick_the_awesome", + "Years": 999, + } + + @pytest.mark.parametrize("fmt", ["rfc", "rfc822"]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], + ) + def test_datetime_field_rfc822(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize( + ("fmt", "value", "expected"), + [ + ("timestamp", dt.datetime(1970, 1, 1), 0), + ("timestamp", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025, + ), + ( + "timestamp", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625, + ), + ("timestamp_ms", dt.datetime(2013, 11, 10, 0, 23, 45), 1384043025000), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=dt.timezone.utc), + 1384043025000, + ), + ( + "timestamp_ms", + dt.datetime(2013, 11, 10, 0, 23, 45, tzinfo=central), + 1384064625000, + ), + ], + ) + def test_datetime_field_timestamp(self, fmt, value, expected): + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], + ) + def test_datetime_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.DateTime() + else: + field = fields.DateTime(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_datetime_field_format(self, user): + format = "%Y-%m-%d" + field = fields.DateTime(format=format) + assert field.serialize("created", user) == user.created.strftime(format) + + def test_string_field(self): + field = fields.String() + user = User(name=b"foo") + assert field.serialize("name", user) == "foo" + field = fields.String(allow_none=True) + user.name = None + assert field.serialize("name", user) is None + + def test_string_field_default_to_empty_string(self, user): + field = fields.String(dump_default="") + assert field.serialize("notfound", {}) == "" + + def test_time_field(self, user): + field = fields.Time() + expected = user.time_registered.isoformat()[:15] + assert field.serialize("time_registered", user) == expected + + user.time_registered = None + assert field.serialize("time_registered", user) is None + + @pytest.mark.parametrize("fmt", ["iso", "iso8601", None]) + @pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.time(1, 23, 45), "01:23:45"), + (dt.time(1, 23, 45, 123000), "01:23:45.123000"), + (dt.time(1, 23, 45, 123456), "01:23:45.123456"), + ], + ) + def test_time_field_iso8601(self, fmt, value, expected): + if fmt is None: + # Test default is ISO + field = fields.Time() + else: + field = fields.Time(format=fmt) + assert field.serialize("d", {"d": value}) == expected + + def test_time_field_format(self, user): + fmt = "%H:%M:%S" + field = fields.Time(format=fmt) + assert field.serialize("birthtime", user) == user.birthtime.strftime(fmt) + + def test_date_field(self, user): + field = fields.Date() + assert field.serialize("birthdate", user) == user.birthdate.isoformat() + + user.birthdate = None + assert field.serialize("birthdate", user) is None + + def test_timedelta_field(self, user): + user.d1 = dt.timedelta(days=1, seconds=1, microseconds=1) + user.d2 = dt.timedelta(days=0, seconds=86401, microseconds=1) + user.d3 = dt.timedelta(days=0, seconds=0, microseconds=86401000001) + user.d4 = dt.timedelta(days=0, seconds=0, microseconds=0) + user.d5 = dt.timedelta(days=-1, seconds=0, microseconds=0) + user.d6 = dt.timedelta( + days=1, + seconds=1, + microseconds=1, + milliseconds=1, + minutes=1, + hours=1, + weeks=1, + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d1", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d1", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d1", user) == 86401000001 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d1", user) == 24 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d2", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d2", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d2", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d3", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d3", user) == 86401 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d3", user) == 86401000001 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d4", user) == 0 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d4", user) == 0 + + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d5", user) == -1 + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d5", user) == -86400 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d5", user) == -86400000000 + + field = fields.TimeDelta(fields.TimeDelta.WEEKS) + assert field.serialize("d6", user) == 1 + field = fields.TimeDelta(fields.TimeDelta.DAYS) + assert field.serialize("d6", user) == 7 + 1 + field = fields.TimeDelta(fields.TimeDelta.HOURS) + assert field.serialize("d6", user) == 7 * 24 + 24 + 1 + field = fields.TimeDelta(fields.TimeDelta.MINUTES) + assert field.serialize("d6", user) == 7 * 24 * 60 + 24 * 60 + 60 + 1 + d6_seconds = ( + 7 * 24 * 60 * 60 + + 24 * 60 * 60 # 1 week + + 60 * 60 # 1 day + + 60 # 1 hour + + 1 # 1 minute + ) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d6", user) == d6_seconds + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d6", user) == d6_seconds * 1000 + 1 + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS) + assert field.serialize("d6", user) == d6_seconds * 10**6 + 1000 + 1 + + user.d7 = None + assert field.serialize("d7", user) is None + + # https://github.com/marshmallow-code/marshmallow/issues/1856 + user.d8 = dt.timedelta(milliseconds=345) + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS) + assert field.serialize("d8", user) == 345 + + user.d9 = dt.timedelta(milliseconds=1999) + field = fields.TimeDelta(fields.TimeDelta.SECONDS) + assert field.serialize("d9", user) == 1 + + user.d10 = dt.timedelta( + weeks=1, + days=6, + hours=2, + minutes=5, + seconds=51, + milliseconds=10, + microseconds=742, + ) + + field = fields.TimeDelta(fields.TimeDelta.MICROSECONDS, float) + unit_value = dt.timedelta(microseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.MILLISECONDS, float) + unit_value = dt.timedelta(milliseconds=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.SECONDS, float) + assert math.isclose(field.serialize("d10", user), user.d10.total_seconds()) + + field = fields.TimeDelta(fields.TimeDelta.MINUTES, float) + unit_value = dt.timedelta(minutes=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.HOURS, float) + unit_value = dt.timedelta(hours=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.DAYS, float) + unit_value = dt.timedelta(days=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + field = fields.TimeDelta(fields.TimeDelta.WEEKS, float) + unit_value = dt.timedelta(weeks=1).total_seconds() + assert math.isclose( + field.serialize("d10", user), user.d10.total_seconds() / unit_value + ) + + with pytest.raises(ValueError): + fields.TimeDelta(fields.TimeDelta.SECONDS, str) + + def test_datetime_list_field(self): + obj = DateTimeList([dt.datetime.now(dt.timezone.utc), dt.datetime.now()]) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert all(type(each) is str for each in result) + + def test_list_field_serialize_none_returns_none(self): + obj = DateTimeList(None) + field = fields.List(fields.DateTime) + assert field.serialize("dtimes", obj) is None + + def test_list_field_work_with_generator_single_value(self): + def custom_generator(): + yield dt.datetime.now(dt.timezone.utc) + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 1 + + def test_list_field_work_with_generators_multiple_values(self): + def custom_generator(): + yield from [dt.datetime.now(dt.timezone.utc), dt.datetime.now()] + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + + def test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement( # noqa: B950 + self, + ): + def custom_generator(): + yield + yield + + obj = DateTimeList(custom_generator()) + field = fields.List(fields.DateTime, allow_none=True) + result = field.serialize("dtimes", obj) + assert len(result) == 2 + assert result[0] is None + assert result[1] is None + + def test_list_field_work_with_set(self): + custom_set = {1, 2, 3} + obj = IntegerList(custom_set) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert 1 in result + assert 2 in result + assert 3 in result + + def test_list_field_work_with_custom_class_with_iterator_protocol(self): + class IteratorSupportingClass: + def __init__(self, iterable): + self.iterable = iterable + + def __iter__(self): + return iter(self.iterable) + + ints = IteratorSupportingClass([1, 2, 3]) + obj = IntegerList(ints) + field = fields.List(fields.Int) + result = field.serialize("ints", obj) + assert len(result) == 3 + assert result[0] == 1 + assert result[1] == 2 + assert result[2] == 3 + + def test_bad_list_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.List("string") + expected_msg = ( + "The list elements must be a subclass or instance of " + "marshmallow.base.FieldABC" + ) + with pytest.raises(ValueError, match=expected_msg): + fields.List(ASchema) + + def test_datetime_integer_tuple_field(self): + obj = DateTimeIntegerTuple((dt.datetime.now(dt.timezone.utc), 42)) + field = fields.Tuple([fields.DateTime, fields.Integer]) + result = field.serialize("dtime_int", obj) + assert type(result[0]) is str + assert type(result[1]) is int + + def test_tuple_field_serialize_none_returns_none(self): + obj = DateTimeIntegerTuple(None) + field = fields.Tuple([fields.DateTime, fields.Integer]) + assert field.serialize("dtime_int", obj) is None + + def test_bad_tuple_field(self): + class ASchema(Schema): + id = fields.Int() + + with pytest.raises(ValueError): + fields.Tuple(["string"]) + with pytest.raises(ValueError): + fields.Tuple(fields.String) + expected_msg = ( + 'Elements of "tuple_fields" must be subclasses or ' + "instances of marshmallow.base.FieldABC." + ) + with pytest.raises(ValueError, match=expected_msg): + fields.Tuple([ASchema]) + + def test_serialize_does_not_apply_validators(self, user): + field = fields.Field(validate=lambda x: False) + # No validation error raised + assert field.serialize("age", user) == user.age + + def test_constant_field_serialization(self, user): + field = fields.Constant("something") + assert field.serialize("whatever", user) == "something" + + def test_constant_is_always_included_in_serialized_data(self): + class MySchema(Schema): + foo = fields.Constant(42) + + sch = MySchema() + assert sch.dump({"bar": 24})["foo"] == 42 + assert sch.dump({"foo": 24})["foo"] == 42 + + def test_constant_field_serialize_when_omitted(self): + class MiniUserSchema(Schema): + name = fields.Constant("bill") + + s = MiniUserSchema() + assert s.dump({})["name"] == "bill" + + @pytest.mark.parametrize("FieldClass", ALL_FIELDS) + def test_all_fields_serialize_none_to_none(self, FieldClass): + field = FieldClass(allow_none=True) + res = field.serialize("foo", {"foo": None}) + assert res is None + + +class TestSchemaSerialization: + def test_serialize_with_missing_param_value(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + def test_serialize_with_missing_param_callable(self): + class AliasingUserSerializer(Schema): + name = fields.String() + birthdate = fields.DateTime(dump_default=lambda: dt.datetime(2017, 9, 29)) + + data = {"name": "Mick"} + result = AliasingUserSerializer().dump(data) + assert result["name"] == "Mick" + assert result["birthdate"] == "2017-09-29T00:00:00" + + +def test_serializing_named_tuple(): + Point = namedtuple("Point", ["x", "y"]) + + field = fields.Field() + + p = Point(x=4, y=2) + + assert field.serialize("x", p) == 4 + + +def test_serializing_named_tuple_with_meta(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(x=4, y=2) + + class PointSerializer(Schema): + class Meta: + fields = ("x", "y") + + serialized = PointSerializer().dump(p) + assert serialized["x"] == 4 + assert serialized["y"] == 2 + + +def test_serializing_slice(): + values = [{"value": value} for value in range(5)] + slice = itertools.islice(values, None) + + class ValueSchema(Schema): + value = fields.Int() + + serialized = ValueSchema(many=True).dump(slice) + assert serialized == values + + +# https://github.com/marshmallow-code/marshmallow/issues/1163 +def test_nested_field_many_serializing_generator(): + class MySchema(Schema): + name = fields.Str() + + class OtherSchema(Schema): + objects = fields.Nested(MySchema, many=True) + + def gen(): + yield {"name": "foo"} + yield {"name": "bar"} + + obj = {"objects": gen()} + data = OtherSchema().dump(obj) + + assert data.get("objects") == [{"name": "foo"}, {"name": "bar"}] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_utils.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..44baa71f428818a343a77bb916759d6d75112a17 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_utils.py @@ -0,0 +1,282 @@ +import datetime as dt +from collections import namedtuple +from copy import copy, deepcopy +from functools import partial + +import pytest + +from marshmallow import Schema, fields, utils +from tests.base import assert_date_equal, assert_time_equal, central + + +def test_missing_singleton_copy(): + assert copy(utils.missing) is utils.missing + assert deepcopy(utils.missing) is utils.missing + + +PointNT = namedtuple("PointNT", ["x", "y"]) + + +class PointClass: + def __init__(self, x, y): + self.x = x + self.y = y + + +class PointDict(dict): + def __init__(self, x, y): + super().__init__({"x": x}) + self.y = y + + +@pytest.mark.parametrize( + "obj", [PointNT(24, 42), PointClass(24, 42), PointDict(24, 42), {"x": 24, "y": 42}] +) +def test_get_value_from_object(obj): + assert utils.get_value(obj, "x") == 24 + assert utils.get_value(obj, "y") == 42 + + +def test_get_value_from_namedtuple_with_default(): + p = PointNT(x=42, y=None) + # Default is only returned if key is not found + assert utils.get_value(p, "z", default=123) == 123 + # since 'y' is an attribute, None is returned instead of the default + assert utils.get_value(p, "y", default=123) is None + + +class Triangle: + def __init__(self, p1, p2, p3): + self.p1 = p1 + self.p2 = p2 + self.p3 = p3 + self.points = [p1, p2, p3] + + +def test_get_value_for_nested_object(): + tri = Triangle(p1=PointClass(1, 2), p2=PointNT(3, 4), p3={"x": 5, "y": 6}) + assert utils.get_value(tri, "p1.x") == 1 + assert utils.get_value(tri, "p2.x") == 3 + assert utils.get_value(tri, "p3.x") == 5 + + +# regression test for https://github.com/marshmallow-code/marshmallow/issues/62 +def test_get_value_from_dict(): + d = dict(items=["foo", "bar"], keys=["baz", "quux"]) + assert utils.get_value(d, "items") == ["foo", "bar"] + assert utils.get_value(d, "keys") == ["baz", "quux"] + + +def test_get_value(): + lst = [1, 2, 3] + assert utils.get_value(lst, 1) == 2 + + class MyInt(int): + pass + + assert utils.get_value(lst, MyInt(1)) == 2 + + +def test_set_value(): + d = {} + utils.set_value(d, "foo", 42) + assert d == {"foo": 42} + + d = {} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": {}} + utils.set_value(d, "foo.bar", 42) + assert d == {"foo": {"bar": 42}} + + d = {"foo": 42} + with pytest.raises(ValueError): + utils.set_value(d, "foo.bar", 42) + + +def test_is_keyed_tuple(): + Point = namedtuple("Point", ["x", "y"]) + p = Point(24, 42) + assert utils.is_keyed_tuple(p) is True + t = (24, 42) + assert utils.is_keyed_tuple(t) is False + d = {"x": 42, "y": 24} + assert utils.is_keyed_tuple(d) is False + s = "xy" + assert utils.is_keyed_tuple(s) is False + lst = [24, 42] + assert utils.is_keyed_tuple(lst) is False + + +def test_is_collection(): + assert utils.is_collection([1, "foo", {}]) is True + assert utils.is_collection(("foo", 2.3)) is True + assert utils.is_collection({"foo": "bar"}) is False + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "Sun, 10 Nov 2013 01:23:45 -0000"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "Sun, 10 Nov 2013 01:23:45 +0000", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "Sun, 10 Nov 2013 01:23:45 -0600", + ), + ], +) +def test_rfc_format(value, expected): + assert utils.rfcformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (dt.datetime(2013, 11, 10, 1, 23, 45), "2013-11-10T01:23:45"), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45.123456+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + "2013-11-10T01:23:45+00:00", + ), + ( + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + "2013-11-10T01:23:45-06:00", + ), + ], +) +def test_isoformat(value, expected): + assert utils.isoformat(value) == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("Sun, 10 Nov 2013 01:23:45 -0000", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "Sun, 10 Nov 2013 01:23:45 +0000", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + "Sun, 10 Nov 2013 01:23:45 -0600", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_rfc(value, expected): + result = utils.from_rfc(value) + assert type(result) is dt.datetime + assert result == expected + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + ("2013-11-10T01:23:45", dt.datetime(2013, 11, 10, 1, 23, 45)), + ( + "2013-11-10T01:23:45+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=dt.timezone.utc), + ), + ( + # Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251 + "2013-11-10T01:23:45.123+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123000, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45.123456+00:00", + dt.datetime(2013, 11, 10, 1, 23, 45, 123456, tzinfo=dt.timezone.utc), + ), + ( + "2013-11-10T01:23:45-06:00", + dt.datetime(2013, 11, 10, 1, 23, 45, tzinfo=central), + ), + ], +) +def test_from_iso_datetime(value, expected): + result = utils.from_iso_datetime(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_iso_time_with_microseconds(): + t = dt.time(1, 23, 45, 6789) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_time_without_microseconds(): + t = dt.time(1, 23, 45) + formatted = t.isoformat() + result = utils.from_iso_time(formatted) + assert type(result) is dt.time + assert_time_equal(result, t) + + +def test_from_iso_date(): + d = dt.date(2014, 8, 21) + iso_date = d.isoformat() + result = utils.from_iso_date(iso_date) + assert type(result) is dt.date + assert_date_equal(result, d) + + +@pytest.mark.parametrize( + ("value", "expected"), + [ + (1676386740, dt.datetime(2023, 2, 14, 14, 59, 00)), + (1676386740.58, dt.datetime(2023, 2, 14, 14, 59, 00, 580000)), + ], +) +def test_from_timestamp(value, expected): + result = utils.from_timestamp(value) + assert type(result) is dt.datetime + assert result == expected + + +def test_from_timestamp_with_negative_value(): + value = -10 + with pytest.raises(ValueError, match=r"Not a valid POSIX timestamp"): + utils.from_timestamp(value) + + +def test_from_timestamp_with_overflow_value(): + value = 9223372036854775 + with pytest.raises(ValueError): + utils.from_timestamp(value) + + +def test_get_func_args(): + def f1(foo, bar): + pass + + f2 = partial(f1, "baz") + + class F3: + def __call__(self, foo, bar): + pass + + f3 = F3() + + for func in [f1, f2, f3]: + assert utils.get_func_args(func) == ["foo", "bar"] + + +# Regression test for https://github.com/marshmallow-code/marshmallow/issues/540 +def test_function_field_using_type_annotation(): + def get_split_words(value: str): # noqa + return value.split(";") + + class MySchema(Schema): + friends = fields.Function(deserialize=get_split_words) + + data = {"friends": "Clark;Alfred;Robin"} + result = MySchema().load(data) + assert result == {"friends": ["Clark", "Alfred", "Robin"]} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_validate.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_validate.py new file mode 100644 index 0000000000000000000000000000000000000000..fcda4e81639892ad4a2123c6db71f6f45a6bf764 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_validate.py @@ -0,0 +1,983 @@ +"""Tests for marshmallow.validate""" + +import re + +import pytest + +from marshmallow import ValidationError, validate + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "https://example.org", + "ftp://example.org", + "ftps://example.org", + "http://example.co.jp", + "http://www.example.com/a%C2%B1b", + "http://www.example.com/~username/", + "http://info.example.com/?fred", + "http://xn--mgbh0fb.xn--kgbechtv/", + "http://example.com/blue/red%3Fand+green", + "http://www.example.com/?array%5Bkey%5D=value", + "http://xn--rsum-bpad.example.org/", + "http://123.45.67.8/", + "http://123.45.67.8:8329/", + "http://[2001:db8::ff00:42]:8329", + "http://[2001::1]:8329", + "http://www.example.com:8000/foo", + "http://user@example.com", + "http://user:pass@example.com", + "http://:pass@example.com", + "http://@example.com", + "http://AZaz09-._~%2A!$&'()*+,;=:@example.com", + ], +) +def test_url_absolute_valid(valid_url): + validator = validate.URL(relative=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http:///example.com/", + "https:///example.com/", + "https://example.org\\", + "https://example.org\n", + "ftp:///example.com/", + "ftps:///example.com/", + "http//example.org", + "http:///", + "http:/example.org", + "foo://example.org", + "../icons/logo.gif", + "http://2001:db8::ff00:42:8329", + "http://[192.168.1.1]:8329", + "abc", + "..", + "/", + " ", + "", + None, + "http://user@pass@example.com", + "http://@pass@example.com", + "http://@@example.com", + "http://^@example.com", + "http://%0G@example.com", + "http://%@example.com", + ], +) +def test_url_absolute_invalid(invalid_url): + validator = validate.URL(relative=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + "/foo/bar", + "/foo?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_valid(valid_url): + validator = validate.URL(relative=True) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( # noqa: W605 + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + None, + ], +) +def test_url_relative_invalid(invalid_url): + validator = validate.URL(relative=True) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "/foo/bar", + "/foo?bar", + "?bar", + "/foo?bar#baz", + ], +) +def test_url_relative_only_valid(valid_url): + validator = validate.URL(relative=True, absolute=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example.org", + "http://example.org\n", + "suppliers.html", + "../icons/logo.gif", + "icons/logo.gif", + "../.../g", + "...", + "\\", + " ", + "", + "http://example.org", + "http://123.45.67.8/", + "http://example.com/foo/bar/../baz", + "https://example.com/../icons/logo.gif", + "http://example.com/./icons/logo.gif", + "ftp://example.com/../../../../g", + "http://example.com/g?y/./x", + ], +) +def test_url_relative_only_invalid(invalid_url): + validator = validate.URL(relative=True, absolute=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +@pytest.mark.parametrize( + "valid_url", + [ + "http://example.org", + "http://123.45.67.8/", + "http://example", + "http://example.", + "http://example:80", + "http://user.name:pass.word@example", + "http://example/foo/bar", + ], +) +def test_url_dont_require_tld_valid(valid_url): + validator = validate.URL(require_tld=False) + assert validator(valid_url) == valid_url + + +@pytest.mark.parametrize( + "invalid_url", + [ + "http//example", + "http://example\n", + "http://.example.org", + "http:///foo/bar", + "http:// /foo/bar", + "", + None, + ], +) +def test_url_dont_require_tld_invalid(invalid_url): + validator = validate.URL(require_tld=False) + with pytest.raises(ValidationError): + validator(invalid_url) + + +def test_url_custom_scheme(): + validator = validate.URL() + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_relative_and_custom_schemes(): + validator = validate.URL(relative=True) + # By default, ws not allowed + url = "ws://test.test" + with pytest.raises(ValidationError): + validator(url) + + validator = validate.URL(relative=True, schemes={"http", "https", "ws"}) + assert validator(url) == url + + +def test_url_custom_message(): + validator = validate.URL(error="{input} ain't an URL") + with pytest.raises(ValidationError, match="invalid ain't an URL"): + validator("invalid") + + +def test_url_repr(): + assert repr( + validate.URL(relative=False, error=None) + ) == "".format("Not a valid URL.") + assert repr( + validate.URL(relative=True, error="foo") + ) == "".format("foo") + assert repr( + validate.URL(relative=True, absolute=False, error="foo") + ) == "".format("foo") + + +def test_url_rejects_invalid_relative_usage(): + with pytest.raises( + ValueError, + match="URL validation cannot set both relative and absolute to False", + ): + validate.URL(relative=False, absolute=False) + + +@pytest.mark.parametrize( + "valid_email", + [ + "niceandsimple@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM", + "very.common@example.com", + "a.little.lengthy.but.fine@a.iana-servers.net", + "disposable.style.email.with+symbol@example.com", + '"very.unusual.@.unusual.com"@example.com', + "!#$%&'*+-/=?^_`{}|~@example.org", + "niceandsimple@[64.233.160.0]", + "niceandsimple@localhost", + "josé@blah.com", + "δοκ.ιμή@παράδειγμα.δοκιμή", + ], +) +def test_email_valid(valid_email): + validator = validate.Email() + assert validator(valid_email) == valid_email + + +@pytest.mark.parametrize( + "invalid_email", + [ + "niceandsimple\n@example.com", + "NiCeAnDsImPlE@eXaMpLe.CoM\n", + 'a"b(c)d,e:f;gi[j\\k]l@example.com', + 'just"not"right@example.com', + 'this is"not\allowed@example.com', + 'this\\ still\\"not\\\\allowed@example.com', + '"much.more unusual"@example.com', + '"very.(),:;<>[]".VERY."very@\\ "very".unusual"@strange.example.com', + '" "@example.org', + "user@example", + "@nouser.com", + "example.com", + "user", + "", + None, + ], +) +def test_email_invalid(invalid_email): + validator = validate.Email() + with pytest.raises(ValidationError): + validator(invalid_email) + + +def test_email_custom_message(): + validator = validate.Email(error="{input} is not an email addy.") + with pytest.raises(ValidationError, match="invalid is not an email addy."): + validator("invalid") + + +def test_email_repr(): + assert repr(validate.Email(error=None)) == "".format( + "Not a valid email address." + ) + assert repr(validate.Email(error="foo")) == "".format("foo") + + +def test_range_min(): + assert validate.Range(1, 2)(1) == 1 + assert validate.Range(0)(1) == 1 + assert validate.Range()(1) == 1 + assert validate.Range(min_inclusive=False, max_inclusive=False)(1) == 1 + assert validate.Range(1, 1)(1) == 1 + + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2, 3)(1) + with pytest.raises(ValidationError, match="Must be greater than or equal to 2"): + validate.Range(2)(1) + with pytest.raises(ValidationError, match="Must be greater than 1"): + validate.Range(1, 2, min_inclusive=False, max_inclusive=True, error=None)(1) + with pytest.raises(ValidationError, match="less than 1"): + validate.Range(1, 1, min_inclusive=True, max_inclusive=False, error=None)(1) + + +def test_range_max(): + assert validate.Range(1, 2)(2) == 2 + assert validate.Range(None, 2)(2) == 2 + assert validate.Range()(2) == 2 + assert validate.Range(min_inclusive=False, max_inclusive=False)(2) == 2 + assert validate.Range(2, 2)(2) == 2 + + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(0, 1)(2) + with pytest.raises(ValidationError, match="less than or equal to 1"): + validate.Range(None, 1)(2) + with pytest.raises(ValidationError, match="less than 2"): + validate.Range(1, 2, min_inclusive=True, max_inclusive=False, error=None)(2) + with pytest.raises(ValidationError, match="greater than 2"): + validate.Range(2, 2, min_inclusive=False, max_inclusive=True, error=None)(2) + + +def test_range_custom_message(): + v = validate.Range(2, 3, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="1 is not between 2 and 3"): + v(1) + + v = validate.Range(2, None, error="{input} is less than {min}") + with pytest.raises(ValidationError, match="1 is less than 2"): + v(1) + + v = validate.Range(None, 3, error="{input} is greater than {max}") + with pytest.raises(ValidationError, match="4 is greater than 3"): + v(4) + + +def test_range_repr(): + assert ( + repr( + validate.Range( + min=None, max=None, error=None, min_inclusive=True, max_inclusive=True + ) + ) + == "" # noqa: B950 + ) + assert ( + repr( + validate.Range( + min=1, max=3, error="foo", min_inclusive=False, max_inclusive=False + ) + ) + == "".format( # noqa: B950 + "foo" + ) + ) + + +def test_length_min(): + assert validate.Length(3, 5)("foo") == "foo" + assert validate.Length(3, 5)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(0)("a") == "a" + assert validate.Length(0)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(1, 1)("a") == "a" + assert validate.Length(1, 1)([1]) == [1] + + with pytest.raises(ValidationError): + validate.Length(4, 5)("foo") + with pytest.raises(ValidationError): + validate.Length(4, 5)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(5)("foo") + with pytest.raises(ValidationError): + validate.Length(5)([1, 2, 3]) + + +def test_length_max(): + assert validate.Length(1, 3)("foo") == "foo" + assert validate.Length(1, 3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(None, 1)("a") == "a" + assert validate.Length(None, 1)([1]) == [1] + assert validate.Length()("") == "" + assert validate.Length()([]) == [] + assert validate.Length(2, 2)("ab") == "ab" + assert validate.Length(2, 2)([1, 2]) == [1, 2] + + with pytest.raises(ValidationError): + validate.Length(1, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(1, 2)([1, 2, 3]) + with pytest.raises(ValidationError): + validate.Length(None, 2)("foo") + with pytest.raises(ValidationError): + validate.Length(None, 2)([1, 2, 3]) + + +def test_length_equal(): + assert validate.Length(equal=3)("foo") == "foo" + assert validate.Length(equal=3)([1, 2, 3]) == [1, 2, 3] + assert validate.Length(equal=None)("") == "" + assert validate.Length(equal=None)([]) == [] + + with pytest.raises(ValidationError): + validate.Length(equal=2)("foo") + with pytest.raises(ValidationError): + validate.Length(equal=2)([1, 2, 3]) + + with pytest.raises(ValueError): + validate.Length(1, None, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(None, 5, equal=3)("foo") + with pytest.raises(ValueError): + validate.Length(1, 5, equal=3)("foo") + + +def test_length_custom_message(): + v = validate.Length(5, 6, error="{input} is not between {min} and {max}") + with pytest.raises(ValidationError, match="foo is not between 5 and 6"): + v("foo") + + v = validate.Length(5, None, error="{input} is shorter than {min}") + with pytest.raises(ValidationError, match="foo is shorter than 5"): + v("foo") + + v = validate.Length(None, 2, error="{input} is longer than {max}") + with pytest.raises(ValidationError, match="foo is longer than 2"): + v("foo") + + v = validate.Length(None, None, equal=4, error="{input} does not have {equal}") + with pytest.raises(ValidationError, match="foo does not have 4"): + v("foo") + + +def test_length_repr(): + assert ( + repr(validate.Length(min=None, max=None, error=None, equal=None)) + == "" + ) + assert repr( + validate.Length(min=1, max=3, error="foo", equal=None) + ) == "".format("foo") + assert repr( + validate.Length(min=None, max=None, error="foo", equal=5) + ) == "".format("foo") + + +def test_equal(): + assert validate.Equal("a")("a") == "a" + assert validate.Equal(1)(1) == 1 + assert validate.Equal([1])([1]) == [1] + + with pytest.raises(ValidationError): + validate.Equal("b")("a") + with pytest.raises(ValidationError): + validate.Equal(2)(1) + with pytest.raises(ValidationError): + validate.Equal([2])([1]) + + +def test_equal_custom_message(): + v = validate.Equal("a", error="{input} is not equal to {other}.") + with pytest.raises(ValidationError, match="b is not equal to a."): + v("b") + + +def test_equal_repr(): + assert repr( + validate.Equal(comparable=123, error=None) + ) == "".format("Must be equal to {other}.") + assert repr( + validate.Equal(comparable=123, error="foo") + ) == "".format("foo") + + +def test_regexp_str(): + assert validate.Regexp(r"a")("a") == "a" + assert validate.Regexp(r"\w")("_") == "_" + assert validate.Regexp(r"\s")(" ") == " " + assert validate.Regexp(r"1")("1") == "1" + assert validate.Regexp(r"[0-9]+")("1") == "1" + assert validate.Regexp(r"a", re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(r"[0-9]+")("a") + with pytest.raises(ValidationError): + validate.Regexp(r"[a-z]+")("1") + with pytest.raises(ValidationError): + validate.Regexp(r"a")("A") + + +def test_regexp_compile(): + assert validate.Regexp(re.compile(r"a"))("a") == "a" + assert validate.Regexp(re.compile(r"\w"))("_") == "_" + assert validate.Regexp(re.compile(r"\s"))(" ") == " " + assert validate.Regexp(re.compile(r"1"))("1") == "1" + assert validate.Regexp(re.compile(r"[0-9]+"))("1") == "1" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE))("A") == "A" + assert validate.Regexp(re.compile(r"a", re.IGNORECASE), re.IGNORECASE)("A") == "A" + + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[0-9]+"))("a") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"[a-z]+"))("1") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"))("A") + with pytest.raises(ValidationError): + validate.Regexp(re.compile(r"a"), re.IGNORECASE)("A") + + +def test_regexp_custom_message(): + rex = r"[0-9]+" + v = validate.Regexp(rex, error="{input} does not match {regex}") + with pytest.raises(ValidationError, match="a does not match"): + v("a") + + +def test_regexp_repr(): + assert repr( + validate.Regexp(regex="abc", flags=0, error=None) + ) == "".format( + re.compile("abc"), "String does not match expected pattern." + ) + assert repr( + validate.Regexp(regex="abc", flags=re.IGNORECASE, error="foo") + ) == "".format( + re.compile("abc", re.IGNORECASE), "foo" + ) + + +def test_predicate(): + class Dummy: + def _true(self): + return True + + def _false(self): + return False + + def _list(self): + return [1, 2, 3] + + def _empty(self): + return [] + + def _identity(self, arg): + return arg + + d = Dummy() + + assert validate.Predicate("_true")(d) == d + assert validate.Predicate("_list")(d) == d + assert validate.Predicate("_identity", arg=True)(d) == d + assert validate.Predicate("_identity", arg=1)(d) == d + assert validate.Predicate("_identity", arg="abc")(d) == d + + with pytest.raises(ValidationError, match="Invalid input."): + validate.Predicate("_false")(d) + with pytest.raises(ValidationError): + validate.Predicate("_empty")(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=False)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg=0)(d) + with pytest.raises(ValidationError): + validate.Predicate("_identity", arg="")(d) + + +def test_predicate_custom_message(): + class Dummy: + def _false(self): + return False + + def __str__(self): + return "Dummy" + + d = Dummy() + with pytest.raises(ValidationError, match="Dummy._false is invalid!"): + validate.Predicate("_false", error="{input}.{method} is invalid!")(d) + + +def test_predicate_repr(): + assert repr( + validate.Predicate(method="foo", error=None) + ) == "".format( + "foo", {}, "Invalid input." + ) + assert repr( + validate.Predicate(method="foo", error="bar", zoo=1) + ) == "".format( + "foo", {"zoo": 1}, "bar" + ) + + +def test_noneof(): + assert validate.NoneOf([1, 2, 3])(4) == 4 + assert validate.NoneOf("abc")("d") == "d" + assert validate.NoneOf("")([]) == [] + assert validate.NoneOf([])("") == "" + assert validate.NoneOf([])([]) == [] + assert validate.NoneOf([1, 2, 3])(None) is None + + with pytest.raises(ValidationError, match="Invalid input."): + validate.NoneOf([1, 2, 3])(3) + with pytest.raises(ValidationError): + validate.NoneOf("abc")("c") + with pytest.raises(ValidationError): + validate.NoneOf([1, 2, None])(None) + with pytest.raises(ValidationError): + validate.NoneOf("")("") + + +def test_noneof_custom_message(): + with pytest.raises(ValidationError, match=""): + validate.NoneOf([1, 2], error="")(1) + + none_of = validate.NoneOf([1, 2], error="{input} cannot be one of {values}") + with pytest.raises(ValidationError, match="1 cannot be one of 1, 2"): + none_of(1) + + +def test_noneof_repr(): + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error=None) + ) == "".format("Invalid input.") + assert repr( + validate.NoneOf(iterable=[1, 2, 3], error="foo") + ) == "".format("foo") + + +def test_oneof(): + assert validate.OneOf([1, 2, 3])(2) == 2 + assert validate.OneOf("abc")("b") == "b" + assert validate.OneOf("")("") == "" + assert validate.OneOf(dict(a=0, b=1))("a") == "a" + assert validate.OneOf((1, 2, None))(None) is None + + with pytest.raises(ValidationError, match="Must be one of: 1, 2, 3."): + validate.OneOf([1, 2, 3])(4) + with pytest.raises(ValidationError): + validate.OneOf("abc")("d") + with pytest.raises(ValidationError): + validate.OneOf((1, 2, 3))(None) + with pytest.raises(ValidationError): + validate.OneOf([])([]) + with pytest.raises(ValidationError): + validate.OneOf(())(()) + with pytest.raises(ValidationError): + validate.OneOf(dict(a=0, b=1))(0) + with pytest.raises(ValidationError): + validate.OneOf("123")(1) + + +def test_oneof_options(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("3", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2, 3], ["one", "two"]) + expected = [("1", "one"), ("2", "two"), ("3", "")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2], ["one", "two", "three"]) + expected = [("1", "one"), ("2", "two"), ("", "three")] + assert list(oneof.options()) == expected + + oneof = validate.OneOf([1, 2]) + expected = [("1", ""), ("2", "")] + assert list(oneof.options()) == expected + + +def test_oneof_text(): + oneof = validate.OneOf([1, 2, 3], ["one", "two", "three"]) + assert oneof.choices_text == "1, 2, 3" + assert oneof.labels_text == "one, two, three" + + oneof = validate.OneOf([1], ["one"]) + assert oneof.choices_text == "1" + assert oneof.labels_text == "one" + + oneof = validate.OneOf(dict(a=0, b=1)) + assert ", ".join(sorted(oneof.choices_text.split(", "))) == "a, b" + assert oneof.labels_text == "" + + +def test_oneof_custom_message(): + oneof = validate.OneOf([1, 2, 3], error="{input} is not one of {choices}") + expected = "4 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + oneof = validate.OneOf( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4 is not one of one, two, three" + with pytest.raises(ValidationError): + oneof(4) + assert expected in str(expected) + + +def test_oneof_repr(): + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "Must be one of: {choices}." + ) + assert repr( + validate.OneOf(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsonly_in_list(): + assert validate.ContainsOnly([])([]) == [] + assert validate.ContainsOnly([1, 2, 3])([1]) == [1] + assert validate.ContainsOnly([1, 1, 2])([1, 1]) == [1, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2]) == [1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 1]) == [2, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsOnly([1, 2, 3])([3, 1, 2]) == [3, 1, 2] + assert validate.ContainsOnly([1, 2, 3])([2, 3, 1]) == [2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([1, 2, 3, 1]) == [1, 2, 3, 1] + assert validate.ContainsOnly([1, 2, 3])([]) == [] + + with pytest.raises( + ValidationError, + match="One or more of the choices you made was not in: 1, 2, 3.", + ): + validate.ContainsOnly([1, 2, 3])([4]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_contains_only_unhashable_types(): + assert validate.ContainsOnly([[1], [2], [3]])([[1]]) == [[1]] + assert validate.ContainsOnly([[1], [1], [2]])([[1], [1]]) == [[1], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2]]) == [[1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [1]]) == [[2], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([[1], [2], [3]]) == [[1], [2], [3]] + assert validate.ContainsOnly([[1], [2], [3]])([[3], [1], [2]]) == [[3], [1], [2]] + assert validate.ContainsOnly([[1], [2], [3]])([[2], [3], [1]]) == [[2], [3], [1]] + assert validate.ContainsOnly([[1], [2], [3]])([]) == [] + + with pytest.raises(ValidationError): + validate.ContainsOnly([[1], [2], [3]])([[4]]) + with pytest.raises(ValidationError): + validate.ContainsOnly([])([1]) + + +def test_containsonly_in_tuple(): + assert validate.ContainsOnly(())(()) == () + assert validate.ContainsOnly((1, 2, 3))((1,)) == (1,) + assert validate.ContainsOnly((1, 1, 2))((1, 1)) == (1, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2)) == (1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 1)) == (2, 1) + assert validate.ContainsOnly((1, 2, 3))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsOnly((1, 2, 3))((3, 1, 2)) == (3, 1, 2) + assert validate.ContainsOnly((1, 2, 3))((2, 3, 1)) == (2, 3, 1) + assert validate.ContainsOnly((1, 2, 3))(()) == tuple() + with pytest.raises(ValidationError): + validate.ContainsOnly((1, 2, 3))((4,)) + with pytest.raises(ValidationError): + validate.ContainsOnly(())((1,)) + + +def test_contains_only_in_string(): + assert validate.ContainsOnly("")("") == "" + assert validate.ContainsOnly("abc")("a") == "a" + assert validate.ContainsOnly("aab")("aa") == "aa" + assert validate.ContainsOnly("abc")("ab") == "ab" + assert validate.ContainsOnly("abc")("ba") == "ba" + assert validate.ContainsOnly("abc")("abc") == "abc" + assert validate.ContainsOnly("abc")("cab") == "cab" + assert validate.ContainsOnly("abc")("bca") == "bca" + assert validate.ContainsOnly("abc")("") == "" + + with pytest.raises(ValidationError): + validate.ContainsOnly("abc")("d") + with pytest.raises(ValidationError): + validate.ContainsOnly("")("a") + + +def test_containsonly_custom_message(): + containsonly = validate.ContainsOnly( + [1, 2, 3], error="{input} is not one of {choices}" + ) + expected = "4, 5 is not one of 1, 2, 3" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + containsonly = validate.ContainsOnly( + [1, 2, 3], ["one", "two", "three"], error="{input} is not one of {labels}" + ) + expected = "4, 5 is not one of one, two, three" + with pytest.raises(ValidationError): + containsonly([4, 5]) + assert expected in str(expected) + + +def test_containsonly_repr(): + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=None, error=None) + ) == "".format( + "One or more of the choices you made was not in: {choices}." + ) + assert repr( + validate.ContainsOnly(choices=[1, 2, 3], labels=["a", "b", "c"], error="foo") + ) == "".format( + ["a", "b", "c"], "foo" + ) + + +def test_containsnoneof_error_message(): + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1" + ): + validate.ContainsNoneOf([1])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: 1, 2, 3" + ): + validate.ContainsNoneOf([1, 2, 3])([1]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: one, two" + ): + validate.ContainsNoneOf(["one", "two"])(["one"]) + + with pytest.raises( + ValidationError, match="One or more of the choices you made was in: @, !, &, ?" + ): + validate.ContainsNoneOf("@!&?")("@") + + +def test_containsnoneof_in_list(): + assert validate.ContainsNoneOf([])([]) == [] + assert validate.ContainsNoneOf([])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([4])([1, 2, 3]) == [1, 2, 3] + assert validate.ContainsNoneOf([2])([1, 3, 4]) == [1, 3, 4] + assert validate.ContainsNoneOf([1, 2, 3])([4]) == [4] + assert validate.ContainsNoneOf([4])([1, 1, 1, 1]) == [1, 1, 1, 1] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 1, 1])([1, 2, 3]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2])([1, 2]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1])([1, 1, 1, 1]) + + +def test_containsnoneof_unhashable_types(): + assert validate.ContainsNoneOf([[1], [2], [3]])([]) == [] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4]]) == [[4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [4]]) == [[4], [4]] + assert validate.ContainsNoneOf([[1], [2], [3]])([[4], [5]]) == [[4], [5]] + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[1], [2], [3]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[3], [2], [1]]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([[1], [2], [3]])([[2], [3], [1]]) + + +def test_containsnoneof_in_tuple(): + assert validate.ContainsNoneOf(())(()) == () + assert validate.ContainsNoneOf(())((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((4,))((1, 2, 3)) == (1, 2, 3) + assert validate.ContainsNoneOf((2,))((1, 3, 4)) == (1, 3, 4) + assert validate.ContainsNoneOf((1, 2, 3))((4,)) == (4,) + assert validate.ContainsNoneOf((4,))((1, 1, 1, 1)) == (1, 1, 1, 1) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 1, 1))((1, 2, 3)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2))((1, 2)) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1,))((1, 1, 1, 1)) + + +def test_containsnoneof_in_string(): + assert validate.ContainsNoneOf("")("") == "" + assert validate.ContainsNoneOf("")("abc") == "abc" + assert validate.ContainsNoneOf("d")("abc") == "abc" + assert validate.ContainsNoneOf("b")("acd") == "acd" + assert validate.ContainsNoneOf("abc")("d") == "d" + assert validate.ContainsNoneOf("d")("aaaa") == "aaaa" + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("aaa")("abc") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("ab")("ab") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf("a")("aaaa") + + +def test_containsnoneof_custom_message(): + validator = validate.ContainsNoneOf( + [1, 2, 3], error="{input} was in the banned list: {values}" + ) + expected = "1 was in the banned list: 1, 2, 3" + with pytest.raises(ValidationError, match=expected): + validator([1]) + + +def test_containsnoneof_mixing_types(): + with pytest.raises(ValidationError): + validate.ContainsNoneOf("abc")(["a"]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf(["a", "b", "c"])("a") + + with pytest.raises(ValidationError): + validate.ContainsNoneOf((1, 2, 3))([1]) + + with pytest.raises(ValidationError): + validate.ContainsNoneOf([1, 2, 3])((1,)) + + +def is_even(value): + if value % 2 != 0: + raise ValidationError("Not an even value.") + + +def test_and(): + validator = validate.And(validate.Range(min=0), is_even) + assert validator(2) + with pytest.raises(ValidationError) as excinfo: + validator(-1) + errors = excinfo.value.messages + assert errors == ["Must be greater than or equal to 0.", "Not an even value."] + + validator_with_composition = validate.And(validator, validate.Range(max=6)) + assert validator_with_composition(4) + with pytest.raises(ValidationError) as excinfo: + validator_with_composition(7) + + errors = excinfo.value.messages + assert errors == ["Not an even value.", "Must be less than or equal to 6."] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_version_attributes.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_version_attributes.py new file mode 100644 index 0000000000000000000000000000000000000000..d233b39ddf97363d18e0b8499f2bd3601005a322 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tests/test_version_attributes.py @@ -0,0 +1,15 @@ +# ruff: noqa: B018 +import pytest + +import marshmallow + + +def test_version_attributes_deprecated(): + with pytest.warns(DeprecationWarning): + marshmallow.__version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__parsed_version__ + + with pytest.warns(DeprecationWarning): + marshmallow.__version_info__ diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tox.ini b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..526cb0be346c76109c1570430aa5f666d1f3114d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/tests/trusted/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = lint,mypy-test,py{39,310,311,312,313},docs + +[testenv] +extras = tests +commands = pytest {posargs} + +[testenv:lint] +deps = pre-commit~=3.5 +skip_install = true +commands = pre-commit run --all-files + +[testenv:mypy-test] +deps = mypy +commands = mypy --show-error-codes --warn-unused-ignores tests/mypy_test_cases/ + +[testenv:docs] +extras = docs +commands = sphinx-build docs/ docs/_build {posargs} + +; Below tasks are for development only (not run in CI) + +[testenv:watch-docs] +deps = sphinx-autobuild +extras = docs +commands = sphinx-autobuild --open-browser docs/ docs/_build {posargs} --watch src/marshmallow --delay 2 + +[testenv:watch-readme] +deps = restview +skip_install = true +commands = restview README.rst + +[testenv:benchmark] +usedevelop = true +commands = python performance/benchmark.py --iterations=100 --repeat=3 diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/first-hunk-only.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..345f35d091632f1f5fa84175cc5ed668a656b75f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/first-hunk-only.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/marshmallow/class_registry.py b/src/marshmallow/class_registry.py +index b6b2e3196a99beac9f6b8a0903149f39514c74a4..d41b112e67d49a6b7514dfb4d62a05eb58edc497 100644 +--- a/src/marshmallow/class_registry.py ++++ b/src/marshmallow/class_registry.py +@@ -27,20 +27,45 @@ + + + def register(classname: str, cls: SchemaType) -> None: ++ """Add a class to the registry of serializer classes. When a class is ++ registered, an entry for both its classname and its full, module-qualified ++ path are added to the registry. ++ ++ Example: :: ++ ++ class MyClass: ++ pass ++ ++ ++ register("MyClass", MyClass) ++ # Registry: ++ # { ++ # 'MyClass': [path.to.MyClass], ++ # 'path.to.MyClass': [path.to.MyClass], ++ # } ++ ++ """ ++ # Module where the class is located + module = cls.__module__ ++ # Full module path to the class ++ # e.g. user.schemas.UserSchema + fullpath = ".".join([module, classname]) +- +- if classname in _registry and any( ++ # If the class is already registered; need to check if the entries are ++ # in the same module as cls to avoid having multiple instances of the same ++ # class in the registry ++ if classname in _registry and not any( + each.__module__ == module for each in _registry[classname] + ): +- del _registry[classname] ++ _registry[classname].append(cls) + elif classname not in _registry: + _registry[classname] = [cls] + ++ # Also register the full path + if fullpath not in _registry: ++ _registry.setdefault(fullpath, []).append(cls) ++ else: ++ # If fullpath does exist, replace existing entry + _registry[fullpath] = [cls] +- else: +- _registry[fullpath].append(cls) + return None + + +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/original-bug.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/openenv.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__w6t6b3ut/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/LICENSE.source b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b20df7cab259cfce3d02bd8da515ce65870612b7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/LICENSE.source @@ -0,0 +1,19 @@ +Copyright Steven Loria and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/adapter.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..da6938d3f1b0602e38126df6a9a19729231bb8b2 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/adapter.json @@ -0,0 +1,127 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "2a75d35790f6496f754850af247239363d8226867be0988241601d82a0eefc59", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "62d8a53bdf6361dcd6d058029baf7da1087f768e422c9ec25687c790aa028fe2", + "gold_patch_sha256": "d88d9a1dad7f1cd097612b133fcef218a91e1b0ab95453f2dfcfabdbe0f755f3", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "1fa372aef309bd0ec9c136dada7ce52aa68d284d13bb54c48f50a9257267c54e", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "702ca0ecf25da131b0b0079f9f7994d01a7edf5d0cd312dac0c829d7b3808d1f", + "partial_repair_wrongness_established": false, + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/marshmallow-code__marshmallow.9716fc62.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "ac1a63e6ac1c79abdd8dc8291bab37382ff139dd", + "source_completion_sha256": "03679e1b8eafc0d80c30701cf7b3cf09bea8f53b33e0761e10d7b91c1c7849f0", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "23d975b32475a8674ea4a01f0eccd6e9167ad90e1d8ce9b6b50f68e7aa285319", + "is_fork": true, + "learner_path": "tasks/a1a8c83e69aab56896b6772f/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/ac1a63e6ac1c79abdd8dc8291bab37382ff139dd/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b914a2268e897bdb43ea1170c6bc4851b98bc7bca3d33496e6869ca4b7a424af", + "provenance_path": "tasks/a1a8c83e69aab56896b6772f/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ac1a63e6ac1c79abdd8dc8291bab37382ff139dd", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2180624327b1ff085ee9e690c208c8649586e1b2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "task_sha256": "445942f8a17749e159756a653c2921aeff332ee4a9c40252dd97d88a672ee7ad", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "symlink_submodule_changes_supported": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "marshmallow-code/marshmallow" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/dependency-setup.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..35a236d9370f89c608fd6e358f7a6d2b90ce6f0a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install -e . +python -m pip install -e '.[tests]' diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/environment/Dockerfile b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/instruction.md b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0a5e6b998e7a8d5af113cc3582460c78680a2d14 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/instruction.md @@ -0,0 +1,36 @@ +Error handling broken after recent changes + +#### Description + +Schema validation is not working properly - errors are not being stored or raised when they should be. When trying to validate invalid data, no ValidationError is raised and the errors dictionary comes back empty. + +#### Steps/Code to Reproduce + +```python +from marshmallow import Schema, fields, ValidationError + +class MySchema(Schema): + email = fields.Email() + +schema = MySchema() +try: + result = schema.load({'email': 'invalid-email'}) + print("No error raised - this is wrong!") + print(f"Result: {result}") +except ValidationError as e: + print(f"Validation error: {e.messages}") + +# Also try validate method +errors = schema.validate({'email': 'invalid-email'}) +print(f"Validate errors: {errors}") # Should contain email validation error but doesn't +``` + +Expected behavior: ValidationError should be raised with proper error messages for invalid email format. + +Actual behavior: No ValidationError is raised and validate() returns empty dict instead of error messages. + +This seems to affect all field validation - required fields, custom validators, nested schemas, etc. The error storage mechanism appears to be completely broken. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/metadata.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..e4996ccd05a143f5c593fdc03eebfe9536f435c7 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/metadata.json @@ -0,0 +1,1398 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message" + ], + "PASS_TO_PASS": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "2180624327b1ff085ee9e690c208c8649586e1b2", + "healthy": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "learner": "ac1a63e6ac1c79abdd8dc8291bab37382ff139dd" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.github/FUNDING.yml", + "/testbed/.github/dependabot.yml", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/.readthedocs.yml", + "/testbed/AUTHORS.rst", + "/testbed/CHANGELOG.rst", + "/testbed/CODE_OF_CONDUCT.md", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE", + "/testbed/NOTICE", + "/testbed/README.rst", + "/testbed/RELEASING.md", + "/testbed/SECURITY.md", + "/testbed/docs/.gitignore", + "/testbed/docs/_static/css/sponsor-message.css", + "/testbed/docs/_static/css/versionwarning.css", + "/testbed/docs/_static/marshmallow-logo.png", + "/testbed/docs/_templates/donate.html", + "/testbed/docs/_templates/useful-links.html", + "/testbed/docs/about.rst.inc", + "/testbed/docs/api_reference.rst", + "/testbed/docs/authors.rst", + "/testbed/docs/changelog.rst", + "/testbed/docs/code_of_conduct.rst", + "/testbed/docs/conf.py", + "/testbed/docs/contributing.rst", + "/testbed/docs/custom_fields.rst", + "/testbed/docs/dashing.json", + "/testbed/docs/ecosystem.rst", + "/testbed/docs/examples.rst", + "/testbed/docs/extending.rst", + "/testbed/docs/index.rst", + "/testbed/docs/install.rst", + "/testbed/docs/kudos.rst", + "/testbed/docs/license.rst", + "/testbed/docs/marshmallow.class_registry.rst", + "/testbed/docs/marshmallow.decorators.rst", + "/testbed/docs/marshmallow.error_store.rst", + "/testbed/docs/marshmallow.exceptions.rst", + "/testbed/docs/marshmallow.fields.rst", + "/testbed/docs/marshmallow.schema.rst", + "/testbed/docs/marshmallow.utils.rst", + "/testbed/docs/marshmallow.validate.rst", + "/testbed/docs/nesting.rst", + "/testbed/docs/quickstart.rst", + "/testbed/docs/upgrading.rst", + "/testbed/docs/whos_using.rst", + "/testbed/docs/why.rst", + "/testbed/examples/flask_example.py", + "/testbed/examples/inflection_example.py", + "/testbed/examples/package_json_example.py", + "/testbed/examples/peewee_example.py", + "/testbed/examples/textblob_example.py", + "/testbed/performance/benchmark.py", + "/testbed/pyproject.toml", + "/testbed/src/marshmallow/__init__.py", + "/testbed/src/marshmallow/base.py", + "/testbed/src/marshmallow/class_registry.py", + "/testbed/src/marshmallow/decorators.py", + "/testbed/src/marshmallow/error_store.py", + "/testbed/src/marshmallow/exceptions.py", + "/testbed/src/marshmallow/fields.py", + "/testbed/src/marshmallow/orderedset.py", + "/testbed/src/marshmallow/py.typed", + "/testbed/src/marshmallow/schema.py", + "/testbed/src/marshmallow/types.py", + "/testbed/src/marshmallow/utils.py", + "/testbed/src/marshmallow/validate.py", + "/testbed/src/marshmallow/warnings.py", + "/testbed/tests/__init__.py", + "/testbed/tests/base.py", + "/testbed/tests/conftest.py", + "/testbed/tests/foo_serializer.py", + "/testbed/tests/mypy_test_cases/test_validation_error.py", + "/testbed/tests/test_exceptions.py", + "/testbed/tests/test_options.py", + "/testbed/tests/test_registry.py", + "/testbed/tests/test_serialization.py", + "/testbed/tests/test_utils.py", + "/testbed/tests/test_validate.py", + "/testbed/tests/test_version_attributes.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Marshmallow9716fc62", + "profile_lines": [ + 542, + 545 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "private_test_paths": [ + "tests/test_decorators.py", + "tests/test_deserialization.py", + "tests/test_error_store.py", + "tests/test_fields.py", + "tests/test_schema.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/marshmallow/error_store.py" + ], + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_stages_bytes": 2185235, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "marshmallow-code/marshmallow" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "23d975b32475a8674ea4a01f0eccd6e9167ad90e1d8ce9b6b50f68e7aa285319", + "is_fork": true, + "learner_path": "tasks/a1a8c83e69aab56896b6772f/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/ac1a63e6ac1c79abdd8dc8291bab37382ff139dd/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b914a2268e897bdb43ea1170c6bc4851b98bc7bca3d33496e6869ca4b7a424af", + "provenance_path": "tasks/a1a8c83e69aab56896b6772f/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ac1a63e6ac1c79abdd8dc8291bab37382ff139dd", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2180624327b1ff085ee9e690c208c8649586e1b2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "task_sha256": "445942f8a17749e159756a653c2921aeff332ee4a9c40252dd97d88a672ee7ad", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provenance.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..9463fb5b4edbca2baa53edc03554b9dd3bbc2b0c --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "d88d9a1dad7f1cd097612b133fcef218a91e1b0ab95453f2dfcfabdbe0f755f3", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/ac1a63e6ac1c79abdd8dc8291bab37382ff139dd/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "03679e1b8eafc0d80c30701cf7b3cf09bea8f53b33e0761e10d7b91c1c7849f0", + "source_index_sha256": "a8bacb23b190ac8227d8d322773176a10ed65e6b16cccd869cb625a465522876", + "source_proof_sha256": "4f5809f09d35bf633854f4dfe5a256bfb1a1c67a9dd2094c93bd43754c271ac4", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "f817ef2c570f1a9099f1861cd6f858aa5a3647d3", + "instruction_sha256": "23d975b32475a8674ea4a01f0eccd6e9167ad90e1d8ce9b6b50f68e7aa285319", + "is_fork": true, + "learner_path": "tasks/a1a8c83e69aab56896b6772f/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "actual_upstream_url": "https://raw.githubusercontent.com/marshmallow-code/marshmallow/9716fc629976c9d3ce30cd15d270d9ac235eb725/LICENSE", + "reviewed": true, + "sha256": "906b5d9051e426144cb173ad911667b8ebd05a9c584c2c26c135b32a3ed12001", + "spdx": "MIT", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/marshmallow-code__marshmallow.9716fc62/ac1a63e6ac1c79abdd8dc8291bab37382ff139dd/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "9716fc629976c9d3ce30cd15d270d9ac235eb725", + "patch_sha256": "b914a2268e897bdb43ea1170c6bc4851b98bc7bca3d33496e6869ca4b7a424af", + "provenance_path": "tasks/a1a8c83e69aab56896b6772f/source-proof.json", + "repository_lineage": [ + "swesmith/marshmallow-code__marshmallow.9716fc62", + "marshmallow-code/marshmallow" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "ac1a63e6ac1c79abdd8dc8291bab37382ff139dd", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "2180624327b1ff085ee9e690c208c8649586e1b2", + "source_kind": "mutation", + "source_repo": "swesmith/marshmallow-code__marshmallow.9716fc62", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4", + "task_sha256": "445942f8a17749e159756a653c2921aeff332ee4a9c40252dd97d88a672ee7ad", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "marshmallow-code/marshmallow", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "243afcb5de791cd2f1414e5f202f22f044a7b2030afe5f47f7c3449d44482b91" +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provided-gold.diff b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..1230df1d592ba198527e7ce1da46a7fc13eec2a1 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/provided-gold.diff @@ -0,0 +1,66 @@ +diff --git a/src/marshmallow/error_store.py b/src/marshmallow/error_store.py +index 419d43eaa143bf995a9e3b497369ab3a7a30282d..72b703736428168885ab02a800d8f755cc4d3bf6 100644 +--- a/src/marshmallow/error_store.py ++++ b/src/marshmallow/error_store.py +@@ -15,11 +15,14 @@ + self.errors = {} + + def store_error(self, messages, field_name=SCHEMA, index=None): +- if field_name == SCHEMA and isinstance(messages, dict): +- messages = [messages] +- if index == 0: ++ # field error -> store/merge error messages under field name key ++ # schema error -> if string or list, store/merge under _schema key ++ # -> if dict, store/merge with other top-level keys ++ if field_name != SCHEMA or not isinstance(messages, dict): + messages = {field_name: messages} +- self.errors = merge_errors(messages, self.errors) ++ if index is not None: ++ messages = {index: messages} ++ self.errors = merge_errors(self.errors, messages) + + + def merge_errors(errors1, errors2): +@@ -29,29 +32,29 @@ + parameter of :exc:`marshmallow.exceptions.ValidationError`. + """ + if not errors1: ++ return errors2 ++ if not errors2: + return errors1 +- if not errors2: +- return errors2 + if isinstance(errors1, list): + if isinstance(errors2, list): +- return errors2 + errors1 ++ return errors1 + errors2 + if isinstance(errors2, dict): +- return dict(errors1, **{SCHEMA: merge_errors(errors2.get(SCHEMA), errors1)}) +- return [errors1] + errors2 ++ return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))}) ++ return errors1 + [errors2] + if isinstance(errors1, dict): + if isinstance(errors2, list): +- return dict(errors2, **{SCHEMA: merge_errors(errors2, errors1.get(SCHEMA))}) ++ return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)}) + if isinstance(errors2, dict): +- errors = dict(errors2) +- for key, val in errors1.items(): ++ errors = dict(errors1) ++ for key, val in errors2.items(): + if key in errors: +- errors[key] = merge_errors(val, errors[key]) ++ errors[key] = merge_errors(errors[key], val) + else: + errors[key] = val + return errors +- return dict(errors2, **{SCHEMA: merge_errors(errors2, errors1.get(SCHEMA))}) ++ return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)}) + if isinstance(errors2, list): +- return errors2 + [errors1] ++ return [errors1] + errors2 + if isinstance(errors2, dict): +- return dict(errors1, **{SCHEMA: merge_errors(errors2.get(SCHEMA), errors1)}) +- return [errors2, errors1] ++ return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))}) ++ return [errors1, errors2] diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/solution/solve.sh b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c60e03144bfa2a1ec266a6b9c0d9dfddaef1c63a --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/solution/solve.sh @@ -0,0 +1,72 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/marshmallow/error_store.py b/src/marshmallow/error_store.py +index 419d43eaa143bf995a9e3b497369ab3a7a30282d..72b703736428168885ab02a800d8f755cc4d3bf6 100644 +--- a/src/marshmallow/error_store.py ++++ b/src/marshmallow/error_store.py +@@ -15,11 +15,14 @@ + self.errors = {} + + def store_error(self, messages, field_name=SCHEMA, index=None): +- if field_name == SCHEMA and isinstance(messages, dict): +- messages = [messages] +- if index == 0: ++ # field error -> store/merge error messages under field name key ++ # schema error -> if string or list, store/merge under _schema key ++ # -> if dict, store/merge with other top-level keys ++ if field_name != SCHEMA or not isinstance(messages, dict): + messages = {field_name: messages} +- self.errors = merge_errors(messages, self.errors) ++ if index is not None: ++ messages = {index: messages} ++ self.errors = merge_errors(self.errors, messages) + + + def merge_errors(errors1, errors2): +@@ -29,29 +32,29 @@ + parameter of :exc:`marshmallow.exceptions.ValidationError`. + """ + if not errors1: ++ return errors2 ++ if not errors2: + return errors1 +- if not errors2: +- return errors2 + if isinstance(errors1, list): + if isinstance(errors2, list): +- return errors2 + errors1 ++ return errors1 + errors2 + if isinstance(errors2, dict): +- return dict(errors1, **{SCHEMA: merge_errors(errors2.get(SCHEMA), errors1)}) +- return [errors1] + errors2 ++ return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))}) ++ return errors1 + [errors2] + if isinstance(errors1, dict): + if isinstance(errors2, list): +- return dict(errors2, **{SCHEMA: merge_errors(errors2, errors1.get(SCHEMA))}) ++ return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)}) + if isinstance(errors2, dict): +- errors = dict(errors2) +- for key, val in errors1.items(): ++ errors = dict(errors1) ++ for key, val in errors2.items(): + if key in errors: +- errors[key] = merge_errors(val, errors[key]) ++ errors[key] = merge_errors(errors[key], val) + else: + errors[key] = val + return errors +- return dict(errors2, **{SCHEMA: merge_errors(errors2, errors1.get(SCHEMA))}) ++ return dict(errors1, **{SCHEMA: merge_errors(errors1.get(SCHEMA), errors2)}) + if isinstance(errors2, list): +- return errors2 + [errors1] ++ return [errors1] + errors2 + if isinstance(errors2, dict): +- return dict(errors1, **{SCHEMA: merge_errors(errors2.get(SCHEMA), errors1)}) +- return [errors2, errors1] ++ return dict(errors2, **{SCHEMA: merge_errors(errors1, errors2.get(SCHEMA))}) ++ return [errors1, errors2] +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/task.toml b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..15487db83aaae9bd99345b631873d1da0dbe45b5 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:09da23004c9fb1134ce380c98afb824a1524de7c1afea4d9f614cdef379e9452" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/check_pytest.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/expected-panels.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..23cbcaa4230250b4ba6ecd8437147fd641aa4863 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/expected-panels.json @@ -0,0 +1,1194 @@ +{ + "fail-to-pass": [ + "tests/test_decorators.py::test_decorated_processor_returning_none[exclude]", + "tests/test_decorators.py::test_decorated_processor_returning_none[include]", + "tests/test_decorators.py::test_decorated_processor_returning_none[raise]", + "tests/test_decorators.py::TestValidatesDecorator::test_validates", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_attribute", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_decorator", + "tests/test_decorators.py::TestValidatesDecorator::test_precedence", + "tests/test_decorators.py::TestValidatesDecorator::test_validates_with_data_key", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_invalid_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_schema_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_field_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[True-expected_data0-expected_original_data0-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_validator_nested_many_pass_original_and_pass_many[False-expected_data1-expected_original_data1-data0]", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_decorated_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_multiple_validators_merge_dict_errors", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_passing_original_data", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_reporting_field_errors_in_schema_validator", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_allow_arbitrary_field_names_in_error", + "tests/test_decorators.py::TestValidatesSchemaDecorator::test_skip_on_field_errors", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_that_raises_error_with_list", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_none_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_non_not_allowed", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_many_required_missing", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_field_name_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_error_returns_data_key_not_attribute_name", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_raises_with_errors_with_multiple_validators", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialization_many_raises_errors", + "tests/test_deserialization.py::TestSchemaDeserialization::test_validation_errors_are_stored", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_an_email_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_multiple_errors_can_be_stored_for_a_url_field", + "tests/test_deserialization.py::TestSchemaDeserialization::test_required_value_only_passed_to_validators_if_provided", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_fields_validation", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_precedence", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_data_key", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_deserialization_with_index_errors_false", + "tests/test_deserialization.py::TestSchemaDeserialization::test_dump_only_fields_considered_unknown", + "tests/test_deserialization.py::TestValidation::test_method_validator", + "tests/test_deserialization.py::TestValidation::test_nested_data_is_stored_when_validation_fails", + "tests/test_deserialization.py::TestValidation::test_false_value_validation", + "tests/test_deserialization.py::TestValidation::test_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_deeply_nested_partial_load", + "tests/test_deserialization.py::TestValidation::test_nested_partial_tuple", + "tests/test_deserialization.py::TestValidation::test_nested_partial_default", + "tests/test_deserialization.py::test_required_field_failure[String]", + "tests/test_deserialization.py::test_required_field_failure[Integer]", + "tests/test_deserialization.py::test_required_field_failure[Boolean]", + "tests/test_deserialization.py::test_required_field_failure[Float]", + "tests/test_deserialization.py::test_required_field_failure[Number]", + "tests/test_deserialization.py::test_required_field_failure[DateTime]", + "tests/test_deserialization.py::test_required_field_failure[Time]", + "tests/test_deserialization.py::test_required_field_failure[Date]", + "tests/test_deserialization.py::test_required_field_failure[TimeDelta]", + "tests/test_deserialization.py::test_required_field_failure[Dict]", + "tests/test_deserialization.py::test_required_field_failure[Url]", + "tests/test_deserialization.py::test_required_field_failure[Email]", + "tests/test_deserialization.py::test_required_field_failure[UUID]", + "tests/test_deserialization.py::test_required_field_failure[Decimal]", + "tests/test_deserialization.py::test_required_field_failure[IP]", + "tests/test_deserialization.py::test_required_field_failure[IPv4]", + "tests/test_deserialization.py::test_required_field_failure[IPv6]", + "tests/test_deserialization.py::test_required_field_failure[IPInterface]", + "tests/test_deserialization.py::test_required_field_failure[IPv4Interface]", + "tests/test_deserialization.py::test_required_field_failure[IPv6Interface]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass20]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass21]", + "tests/test_deserialization.py::test_required_field_failure[FieldClass22]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message1]", + "tests/test_deserialization.py::test_required_message_can_be_changed[message2]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[True-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[False-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[42-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[None-raise]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-exclude]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-include]", + "tests/test_deserialization.py::test_deserialize_raises_exception_if_input_type_is_incorrect[data4-raise]", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_none_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_none", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_string_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_custom_error_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_merging_list_and_dict_with_schema_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_string", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_custom_error", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_list", + "tests/test_error_store.py::TestMergeErrors::test_merging_dict_and_dict", + "tests/test_error_store.py::TestMergeErrors::test_deep_merging_dicts", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[nested_value0]", + "tests/test_fields.py::TestNestedField::test_nested_instantiation_from_dict[]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise]", + "tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested", + "tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested", + "tests/test_schema.py::test_load_resets_errors", + "tests/test_schema.py::test_load_validation_error_stores_input_data_and_valid_data", + "tests/test_schema.py::test_load_resets_error_fields", + "tests/test_schema.py::test_errored_fields_do_not_appear_in_output", + "tests/test_schema.py::test_load_many_stores_error_indices", + "tests/test_schema.py::test_multiple_errors_can_be_stored_for_a_given_index", + "tests/test_schema.py::test_load_invalid_input_type[None]", + "tests/test_schema.py::test_load_invalid_input_type[False]", + "tests/test_schema.py::test_load_invalid_input_type[1]", + "tests/test_schema.py::test_load_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_invalid_input_type[val4]", + "tests/test_schema.py::test_load_invalid_input_type[val5]", + "tests/test_schema.py::test_load_invalid_input_type[val6]", + "tests/test_schema.py::test_load_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_invalid_input_type[None]", + "tests/test_schema.py::test_load_many_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_invalid_input_type[val6]", + "tests/test_schema.py::test_load_many_invalid_input_type[lol]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[False]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[1.2]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val3]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val4]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[val5]", + "tests/test_schema.py::test_load_many_in_nested_invalid_input_type[lol]", + "tests/test_schema.py::TestValidate::test_validate_raises_with_errors_dict", + "tests/test_schema.py::TestValidate::test_validate_many", + "tests/test_schema.py::TestValidate::test_validate_many_doesnt_store_index_if_index_errors_option_is_false", + "tests/test_schema.py::TestValidate::test_validate", + "tests/test_schema.py::TestValidate::test_validate_required", + "tests/test_schema.py::test_stores_invalid_url_error[UserSchema]", + "tests/test_schema.py::test_stores_invalid_url_error[UserMetaSchema]", + "tests/test_schema.py::test_stored_invalid_email", + "tests/test_schema.py::test_custom_error_message", + "tests/test_schema.py::test_custom_unknown_error_message", + "tests/test_schema.py::test_custom_type_error_message", + "tests/test_schema.py::test_custom_type_error_message_with_many", + "tests/test_schema.py::test_custom_error_messages_with_inheritance", + "tests/test_schema.py::test_load_errors_with_many", + "tests/test_schema.py::TestFieldValidation::test_errors_are_cleared_after_loading_collection", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_list", + "tests/test_schema.py::TestFieldValidation::test_raises_error_with_dict", + "tests/test_schema.py::TestFieldValidation::test_ignored_if_not_in_only", + "tests/test_schema.py::TestNestedSchema::test_nested", + "tests/test_schema.py::TestNestedSchema::test_nested_errors", + "tests/test_schema.py::TestNestedSchema::test_invalid_type_passed_to_nested_field", + "tests/test_schema.py::TestNestedSchema::test_all_errors_on_many_nested_field_with_validates_decorator", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[None]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[raise]", + "tests/test_schema.py::test_deserialization_with_required_field", + "tests/test_schema.py::test_deserialization_with_required_field_and_custom_validator", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_missing", + "tests/test_schema.py::TestRequiredFields::test_required_string_field_failure", + "tests/test_schema.py::TestRequiredFields::test_allow_none_param", + "tests/test_schema.py::TestRequiredFields::test_allow_none_custom_message" + ], + "pass-to-pass": [ + "tests/test_decorators.py::test_decorated_processors[True]", + "tests/test_decorators.py::test_decorated_processors[False]", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_single", + "tests/test_decorators.py::TestPassOriginal::test_pass_original_many", + "tests/test_decorators.py::test_decorated_processor_inheritance", + "tests/test_decorators.py::test_pre_dump_is_invoked_before_implicit_field_generation", + "tests/test_decorators.py::TestValidatesDecorator::test_field_not_present", + "tests/test_decorators.py::test_decorator_error_handling", + "tests/test_decorators.py::test_decorator_error_handling_with_load[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[pre_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_load_dict_error[post_load]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[pre_dump]", + "tests/test_decorators.py::test_decorator_error_handling_with_dump[post_dump]", + "tests/test_decorators.py::test_decorator_post_dump_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_decorators.py::test_decorator_post_load_with_nested_original_and_pass_many[data0-expected_data0-expected_original_data0]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_allow_none_deserialize_to_none[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[String]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Integer]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Boolean]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Float]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Number]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[DateTime]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Time]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Date]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[TimeDelta]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Dict]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Url]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Email]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[UUID]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[Decimal]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IP]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPInterface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv4Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[IPv6Interface]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass20]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass21]", + "tests/test_deserialization.py::TestDeserializingNone::test_fields_dont_allow_none_by_default[FieldClass22]", + "tests/test_deserialization.py::TestDeserializingNone::test_allow_none_is_true_if_missing_is_true", + "tests/test_deserialization.py::TestDeserializingNone::test_list_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_tuple_field_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_allow_none_deserialize_none_to_none", + "tests/test_deserialization.py::TestDeserializingNone::test_list_of_nested_non_allow_none_deserialize_none_to_validation_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[bad]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[in_val2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_float_field_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_overflow", + "tests/test_deserialization.py::TestFieldDeserialization::test_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_strict_integer_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_with_places_and_rounding", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_deserialization_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_decimal_field_special_values_not_permitted", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-nan-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_float_field_allow_nan[-inf-True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_string_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[notvalid]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_truthy_values_invalid[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_empty_truthy", + "tests/test_deserialization.py::TestFieldDeserialization::test_boolean_field_deserialization_with_custom_falsy_values", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_toggle_show_invalid_value_in_error_message", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[not-a-datetime]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[True]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[False]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[in_value6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_datetime_deserialization[2018-01-01]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_date_format_datetime_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-expected0-False-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45+00:00-expected1-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123+00:00-expected2-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45.123456+00:00-expected3-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_datetime_field_deserialization[2013-11-10T01:23:45-06:00-expected4-True-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.12-expected3]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1384043025.123456-expected4]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp-1-expected5]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1384043025000-expected6]", + "tests/test_deserialization.py::TestFieldDeserialization::test_timestamp_field_deserialization[timestamp_ms-1000-expected7]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[!@#-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[-1-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timestamp_field_deserialization[in_value3-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOSError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp]", + "tests/test_deserialization.py::TestFieldDeserialization::test_oversized_timestamp_field_deserialization[MockDateTimeOverflowError-timestamp_ms]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-None-2013-11-10T01:23:45-expected0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone1-2013-11-10T01:23:45+00:00-expected1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_naive_datetime_with_timezone[iso-timezone2-2013-11-10T01:23:45-03:00-expected2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone0]", + "tests/test_deserialization.py::TestFieldDeserialization::test_aware_datetime_default_timezone[iso-2013-11-10T01:23:45-timezone1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[in_data2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_time_field_deserialization[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_custom_time_format_time_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45-expected0-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45+01:00-expected1-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123-expected2-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-iso8601]", + "tests/test_deserialization.py::TestFieldDeserialization::test_iso_time_field_deserialization[01:23:45.123456-expected3-None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_precision", + "tests/test_deserialization.py::TestFieldDeserialization::test_timedelta_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[badvalue]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_timedelta_field_deserialization[9999999999]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[None]", + "tests/test_deserialization.py::TestFieldDeserialization::test_date_field_deserialization[%Y-%m-%d]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_date_field_deserialization[21-08-2014]", + "tests/test_deserialization.py::TestFieldDeserialization::test_dict_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_structured_dict_key_value_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_relative_url_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_url_field_schemes_argument", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_email_field_non_list_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_deserialization_with_context", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_only_is_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_function_field_passed_deserialize_and_serialize_is_not_load_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_uuid_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[in_value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_uuid_deserialization[tooshort]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ip_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ip_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipinterface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipinterface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv4interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[192.168.0.1/33]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:81d::200e]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv4interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_ipv6interface_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[malformed]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[123]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[\\x01\\x02\\x03]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[ff::aa:1::2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[192.168.0.1/24]", + "tests/test_deserialization.py::TestFieldDeserialization::test_invalid_ipv6interface_deserialization[2a00:1450:4001:824::200e/129]", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_symbol_not_string", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_invalid_value", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_true_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_enum_field_by_value_field_wrong_type", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_function_must_be_callable", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialization_is_noop_by_default", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_deserialization_method_must_be_a_method", + "tests/test_deserialization.py::TestFieldDeserialization::test_method_field_deserialize_only", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_list_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_list_field_deserialize_value_that_is_not_a_list[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_datetime_int_tuple_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_item", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_multiple_invalid_items", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[notalist]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[42]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_value_that_is_not_a_collection[value2]", + "tests/test_deserialization.py::TestFieldDeserialization::test_tuple_field_deserialize_invalid_length", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_field_deserialization", + "tests/test_deserialization.py::TestFieldDeserialization::test_constant_is_always_included_in_deserialized_data", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_function", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validator_class_that_returns_bool", + "tests/test_deserialization.py::TestFieldDeserialization::test_validator_must_return_false_to_raise_error", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_validator_with_nonascii_input", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_user_validators", + "tests/test_deserialization.py::TestFieldDeserialization::test_field_deserialization_with_custom_error_message", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_values", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_many", + "tests/test_deserialization.py::TestSchemaDeserialization::test_exclude", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_single_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_list_deserialization_to_dict", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_only_basestring_with_list_data", + "tests/test_deserialization.py::TestSchemaDeserialization::test_nested_none_deserialization", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_attribute_param_symmetry", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_data_key_as_empty_string", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_dump_only_param", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_value", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_callable", + "tests/test_deserialization.py::TestSchemaDeserialization::test_deserialize_with_missing_param_none", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[True]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_partial_deserialization[False]", + "tests/test_deserialization.py::TestSchemaDeserialization::test_unknown_fields_do_not_unpack_dotted_names", + "tests/test_deserialization.py::TestValidation::test_integer_with_validator", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_integer_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_float_with_validators[field2]", + "tests/test_deserialization.py::TestValidation::test_string_validator", + "tests/test_deserialization.py::TestValidation::test_function_validator", + "tests/test_deserialization.py::TestValidation::test_function_validators[field0]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field1]", + "tests/test_deserialization.py::TestValidation::test_function_validators[field2]", + "tests/test_error_store.py::test_missing_is_falsy", + "tests/test_exceptions.py::TestValidationError::test_stores_message_in_list", + "tests/test_exceptions.py::TestValidationError::test_can_pass_list_of_messages", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries", + "tests/test_exceptions.py::TestValidationError::test_can_store_field_name", + "tests/test_exceptions.py::TestValidationError::test_str", + "tests/test_exceptions.py::TestValidationError::test_stores_dictionaries_in_messages_dict", + "tests/test_exceptions.py::TestValidationError::test_messages_dict_type_error_on_badval", + "tests/test_fields.py::test_field_aliases[Integer-Integer]", + "tests/test_fields.py::test_field_aliases[String-String]", + "tests/test_fields.py::test_field_aliases[Boolean-Boolean]", + "tests/test_fields.py::test_field_aliases[Url-Url]", + "tests/test_fields.py::TestField::test_repr", + "tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed", + "tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field", + "tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj", + "tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set", + "tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set", + "tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name", + "tests/test_fields.py::TestParentAndName::test_simple_field_root", + "tests/test_fields.py::TestParentAndName::test_list_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root", + "tests/test_fields.py::TestParentAndName::test_list_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_dict_root_inheritance", + "tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format", + "tests/test_fields.py::TestParentAndName::test_field_named_parent_has_root", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IP]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPInterface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[FieldClass22]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestMetadata::test_field_metadata_added_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_load_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[String]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Integer]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Boolean]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Float]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Number]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[DateTime]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Time]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Date]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[TimeDelta]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Dict]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Url]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Email]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[UUID]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[Decimal]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IP]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPInterface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv4Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[IPv6Interface]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass20]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass21]", + "tests/test_fields.py::TestDeprecatedDefaultAndMissing::test_dump_default_in_deprecated_style_warns[FieldClass22]", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg", + "tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages", + "tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only]", + "tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include]", + "tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[only-fields_list0]", + "tests/test_fields.py::TestNestedField::test_nested_schema_only_and_exclude[exclude-fields_list1]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_class_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_class_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestListNested::test_list_nested_instance_multiple_dumps", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[only-expected_attribute0-expected_dump0]", + "tests/test_fields.py::TestListNested::test_list_nested_lambda_only_and_exclude_merged_with_nested[exclude-expected_attribute1-expected_dump1]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0]", + "tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1]", + "tests/test_options.py::TestUnordered::test_unordered_dump_returns_dict", + "tests/test_options.py::TestUnordered::test_unordered_load_returns_dict", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[False]", + "tests/test_options.py::TestFieldOrdering::test_ordered_option_is_inherited[True]", + "tests/test_options.py::TestFieldOrdering::test_ordering_is_off_by_default", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_declared_field_order_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_only_arg_is_maintained_on_load", + "tests/test_options.py::TestFieldOrdering::test_nested_field_order_with_exclude_arg_is_maintained", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_dump", + "tests/test_options.py::TestFieldOrdering::test_meta_fields_order_is_maintained_on_load", + "tests/test_options.py::TestIncludeOption::test_fields_are_added", + "tests/test_options.py::TestIncludeOption::test_included_fields_ordered_after_declared_fields", + "tests/test_options.py::TestIncludeOption::test_added_fields_are_inherited", + "tests/test_options.py::TestManyOption::test_many_by_default", + "tests/test_options.py::TestManyOption::test_explicit_single", + "tests/test_registry.py::test_serializer_has_class_registry", + "tests/test_registry.py::test_register_class_meta_option", + "tests/test_registry.py::test_serializer_class_registry_register_same_classname_different_module", + "tests/test_registry.py::test_serializer_class_registry_override_if_same_classname_same_module", + "tests/test_registry.py::test_two_way_nesting", + "tests/test_registry.py::test_nesting_with_class_name_many", + "tests/test_registry.py::test_invalid_class_name_in_nested_field_raises_error", + "tests/test_registry.py::test_multiple_classes_with_same_name_raises_error", + "tests/test_registry.py::test_multiple_classes_with_all", + "tests/test_registry.py::test_can_use_full_module_path_to_class", + "tests/test_schema.py::test_serializing_basic_object[UserSchema]", + "tests/test_schema.py::test_serializing_basic_object[UserMetaSchema]", + "tests/test_schema.py::test_serializer_dump", + "tests/test_schema.py::test_dump_many", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value0]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value1]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value2]", + "tests/test_schema.py::test_boolean_can_dump_unhashable[value3]", + "tests/test_schema.py::test_dump_returns_a_dict", + "tests/test_schema.py::test_dumps_returns_a_string", + "tests/test_schema.py::test_dumping_single_object_with_collection_schema", + "tests/test_schema.py::test_loading_single_object_with_collection_schema", + "tests/test_schema.py::test_dumps_many", + "tests/test_schema.py::test_load_returns_an_object", + "tests/test_schema.py::test_load_many", + "tests/test_schema.py::test_load_many_empty_collection[val0]", + "tests/test_schema.py::test_load_many_empty_collection[val1]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val0]", + "tests/test_schema.py::test_load_many_in_nested_empty_collection[val1]", + "tests/test_schema.py::test_loads_returns_a_user", + "tests/test_schema.py::test_loads_many", + "tests/test_schema.py::test_loads_deserializes_from_json", + "tests/test_schema.py::test_serializing_none", + "tests/test_schema.py::test_default_many_symmetry", + "tests/test_schema.py::test_on_bind_field_hook", + "tests/test_schema.py::test_nested_on_bind_field_hook", + "tests/test_schema.py::test_fields_are_not_copies[UserSchema]", + "tests/test_schema.py::test_fields_are_not_copies[UserMetaSchema]", + "tests/test_schema.py::test_dumps_returns_json", + "tests/test_schema.py::test_naive_datetime_field", + "tests/test_schema.py::test_datetime_formatted_field", + "tests/test_schema.py::test_datetime_iso_field", + "tests/test_schema.py::test_tz_datetime_field", + "tests/test_schema.py::test_class_variable", + "tests/test_schema.py::test_serialize_many[UserSchema]", + "tests/test_schema.py::test_serialize_many[UserMetaSchema]", + "tests/test_schema.py::test_inheriting_schema", + "tests/test_schema.py::test_custom_field", + "tests/test_schema.py::test_url_field", + "tests/test_schema.py::test_relative_url_field", + "tests/test_schema.py::test_email_field[UserSchema]", + "tests/test_schema.py::test_email_field[UserMetaSchema]", + "tests/test_schema.py::test_integer_field", + "tests/test_schema.py::test_as_string", + "tests/test_schema.py::test_method_field[UserSchema]", + "tests/test_schema.py::test_method_field[UserMetaSchema]", + "tests/test_schema.py::test_function_field", + "tests/test_schema.py::test_fields_must_be_declared_as_instances", + "tests/test_schema.py::test_bind_field_does_not_swallow_typeerror", + "tests/test_schema.py::test_serializing_generator[UserSchema]", + "tests/test_schema.py::test_serializing_generator[UserMetaSchema]", + "tests/test_schema.py::test_serializing_empty_list_returns_empty_list", + "tests/test_schema.py::test_serializing_dict", + "tests/test_schema.py::test_serializing_dict_with_meta_fields", + "tests/test_schema.py::test_exclude_in_init[UserSchema]", + "tests/test_schema.py::test_exclude_in_init[UserMetaSchema]", + "tests/test_schema.py::test_only_in_init[UserSchema]", + "tests/test_schema.py::test_only_in_init[UserMetaSchema]", + "tests/test_schema.py::test_invalid_only_param", + "tests/test_schema.py::test_can_serialize_uuid", + "tests/test_schema.py::test_can_serialize_time", + "tests/test_schema.py::test_json_module_is_deprecated", + "tests/test_schema.py::test_render_module", + "tests/test_schema.py::test_error_raised_if_fields_option_is_not_list", + "tests/test_schema.py::test_error_raised_if_additional_option_is_not_list", + "tests/test_schema.py::test_nested_custom_set_in_exclude_reusing_schema", + "tests/test_schema.py::test_nested_only", + "tests/test_schema.py::test_nested_only_inheritance", + "tests/test_schema.py::test_nested_only_empty_inheritance", + "tests/test_schema.py::test_nested_exclude", + "tests/test_schema.py::test_nested_exclude_inheritance", + "tests/test_schema.py::test_nested_only_and_exclude", + "tests/test_schema.py::test_nested_only_then_exclude_inheritance", + "tests/test_schema.py::test_nested_exclude_then_only_inheritance", + "tests/test_schema.py::test_nested_exclude_and_only_inheritance", + "tests/test_schema.py::test_nested_instance_many", + "tests/test_schema.py::test_nested_instance_only", + "tests/test_schema.py::test_nested_instance_exclude", + "tests/test_schema.py::test_meta_nested_exclude", + "tests/test_schema.py::test_nested_custom_set_not_implementing_getitem", + "tests/test_schema.py::test_deeply_nested_only_and_exclude", + "tests/test_schema.py::test_nested_lambda", + "tests/test_schema.py::test_data_key_collision[f1]", + "tests/test_schema.py::test_data_key_collision[f5]", + "tests/test_schema.py::test_data_key_collision[None]", + "tests/test_schema.py::test_attribute_collision[f1]", + "tests/test_schema.py::test_attribute_collision[f5]", + "tests/test_schema.py::test_attribute_collision[None]", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedLoadOnly::test_dump_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_load_only", + "tests/test_schema.py::TestDeeplyNestedListLoadOnly::test_dump_only", + "tests/test_schema.py::test_nested_constructor_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude", + "tests/test_schema.py::test_only_and_exclude_with_fields", + "tests/test_schema.py::test_invalid_only_and_exclude_with_fields", + "tests/test_schema.py::test_only_and_exclude_with_additional", + "tests/test_schema.py::test_invalid_only_and_exclude_with_additional", + "tests/test_schema.py::test_exclude_invalid_attribute", + "tests/test_schema.py::test_only_bounded_by_fields", + "tests/test_schema.py::test_only_bounded_by_additional", + "tests/test_schema.py::test_only_empty", + "tests/test_schema.py::test_only_and_exclude_as_string[only]", + "tests/test_schema.py::test_only_and_exclude_as_string[exclude]", + "tests/test_schema.py::test_nested_with_sets", + "tests/test_schema.py::test_meta_serializer_fields", + "tests/test_schema.py::test_meta_fields_mapping", + "tests/test_schema.py::test_meta_field_not_on_obj_raises_attribute_error", + "tests/test_schema.py::test_exclude_fields", + "tests/test_schema.py::test_fields_option_must_be_list_or_tuple", + "tests/test_schema.py::test_exclude_option_must_be_list_or_tuple", + "tests/test_schema.py::test_datetimeformat_option", + "tests/test_schema.py::test_dateformat_option", + "tests/test_schema.py::test_timeformat_option", + "tests/test_schema.py::test_default_dateformat", + "tests/test_schema.py::test_inherit_meta", + "tests/test_schema.py::test_inherit_meta_override", + "tests/test_schema.py::test_additional", + "tests/test_schema.py::test_cant_set_both_additional_and_fields", + "tests/test_schema.py::test_serializing_none_meta", + "tests/test_schema.py::test_schema_repr", + "tests/test_schema.py::TestNestedSchema::test_nested_many_with_missing_attribute", + "tests/test_schema.py::TestNestedSchema::test_nested_with_attribute_none", + "tests/test_schema.py::TestNestedSchema::test_nested_field_does_not_validate_required", + "tests/test_schema.py::TestNestedSchema::test_nested_none", + "tests/test_schema.py::TestNestedSchema::test_nested_many_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_meta_many", + "tests/test_schema.py::TestNestedSchema::test_nested_only", + "tests/test_schema.py::TestNestedSchema::test_exclude", + "tests/test_schema.py::TestNestedSchema::test_list_field", + "tests/test_schema.py::TestNestedSchema::test_nested_load_many", + "tests/test_schema.py::TestNestedSchema::test_nested_method_field", + "tests/test_schema.py::TestNestedSchema::test_nested_function_field", + "tests/test_schema.py::TestNestedSchema::test_serializer_meta_with_nested_fields", + "tests/test_schema.py::TestNestedSchema::test_serializer_with_nested_meta_fields", + "tests/test_schema.py::TestNestedSchema::test_nested_fields_must_be_passed_a_serializer", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[include]", + "tests/test_schema.py::TestNestedSchema::test_nested_unknown_validation[exclude]", + "tests/test_schema.py::TestPluckSchema::test_pluck[UserSchema]", + "tests/test_schema.py::TestPluckSchema::test_pluck[user_schema1]", + "tests/test_schema.py::TestPluckSchema::test_pluck_none", + "tests/test_schema.py::TestPluckSchema::test_pluck_with_data_key", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_lambda", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_by_passing_class_name", + "tests/test_schema.py::TestSelfReference::test_nesting_schema_self_string", + "tests/test_schema.py::TestSelfReference::test_nesting_within_itself_meta", + "tests/test_schema.py::TestSelfReference::test_nested_self_with_only_param", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_lambda", + "tests/test_schema.py::TestSelfReference::test_multiple_pluck_self_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_lambda", + "tests/test_schema.py::TestSelfReference::test_nested_self_many_string", + "tests/test_schema.py::TestSelfReference::test_nested_self_list", + "tests/test_schema.py::TestSelfReference::test_nested_self_list_string", + "tests/test_schema.py::test_serialization_with_required_field", + "tests/test_schema.py::TestContext::test_context_method", + "tests/test_schema.py::TestContext::test_context_method_function", + "tests/test_schema.py::TestContext::test_function_field_raises_error_when_context_not_available", + "tests/test_schema.py::TestContext::test_function_field_handles_bound_serializer", + "tests/test_schema.py::TestContext::test_fields_context", + "tests/test_schema.py::TestContext::test_nested_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_list_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_dict_fields_inherit_context", + "tests/test_schema.py::TestContext::test_nested_field_with_unpicklable_object_in_context", + "tests/test_schema.py::test_serializer_can_specify_nested_object_as_attribute", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inherit_fields_from_non_schema_subclass", + "tests/test_schema.py::TestFieldInheritance::test_inheritance_follows_mro", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_is_used", + "tests/test_schema.py::TestGetAttribute::test_get_attribute_with_many", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_dump_output", + "tests/test_schema.py::TestDefaults::test_none_is_serialized_to_none", + "tests/test_schema.py::TestDefaults::test_default_and_value_missing", + "tests/test_schema.py::TestDefaults::test_loading_none", + "tests/test_schema.py::TestDefaults::test_missing_inputs_are_excluded_from_load_output", + "tests/test_schema.py::TestLoadOnly::test_load_only", + "tests/test_schema.py::TestLoadOnly::test_dump_only", + "tests/test_schema.py::TestLoadOnly::test_url_field_requre_tld_false", + "tests/test_schema.py::TestFromDict::test_generates_schema", + "tests/test_schema.py::TestFromDict::test_name", + "tests/test_schema.py::TestFromDict::test_generated_schemas_are_not_registered", + "tests/test_schema.py::TestFromDict::test_meta_options_are_applied", + "tests/test_schema.py::test_class_registry_returns_schema_type", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[meta]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[init]", + "tests/test_schema.py::test_unknown_parameter_value_is_validated[load]", + "tests/test_schema.py::test_set_dict_class[dict]", + "tests/test_schema.py::test_set_dict_class[OrderedDict]", + "tests/test_serialization.py::TestFieldSerialization::test_number[42-42.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[0-0.0]", + "tests/test_serialization.py::TestFieldSerialization::test_number[None-None]", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string", + "tests/test_serialization.py::TestFieldSerialization::test_number_as_string_passed_none", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_func", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_deserialize_and_serialize_is_not_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_load_only_param", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_serialize_with_context", + "tests/test_serialization.py::TestFieldSerialization::test_function_field_passed_uncallable_object", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_as_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default", + "tests/test_serialization.py::TestFieldSerialization::test_integer_field_default_set_to_none", + "tests/test_serialization.py::TestFieldSerialization::test_uuid_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_address_field", + "tests/test_serialization.py::TestFieldSerialization::test_ip_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv4_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_ipv6_interface_field", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_symbol_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_true_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_enum_field_by_value_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_string", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_special_values_not_permitted", + "tests/test_serialization.py::TestFieldSerialization::test_decimal_field_fixed_point_representation", + "tests/test_serialization.py::TestFieldSerialization::test_boolean_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_email_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_dict_field_serialize_ordereddict", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_structured_dict_key_value_serialize", + "tests/test_serialization.py::TestFieldSerialization::test_url_field_serialize_none", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_method_missing", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_serialize_only_is_dump_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_passed_deserialize_only_is_load_only", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_with_uncallable_attribute", + "tests/test_serialization.py::TestFieldSerialization::test_method_field_does_not_swallow_attribute_error", + "tests/test_serialization.py::TestFieldSerialization::test_method_with_no_serialize_is_missing", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_param", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_data_key_as_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_with_attribute_and_data_key_uses_data_key", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value0-0]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value1-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value2-1384043025]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp-value3-1384064625]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value4-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value5-1384043025000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_timestamp[timestamp_ms-value6-1384064625000]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value0-2013-11-10T01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value1-2013-11-10T01:23:45.123456+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value2-2013-11-10T01:23:45+00:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_iso8601[value3-2013-11-10T01:23:45-06:00-None]", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_string_field", + "tests/test_serialization.py::TestFieldSerialization::test_string_field_default_to_empty_string", + "tests/test_serialization.py::TestFieldSerialization::test_time_field", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value0-01:23:45-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value1-01:23:45.123000-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-iso8601]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_iso8601[value2-01:23:45.123456-None]", + "tests/test_serialization.py::TestFieldSerialization::test_time_field_format", + "tests/test_serialization.py::TestFieldSerialization::test_date_field", + "tests/test_serialization.py::TestFieldSerialization::test_timedelta_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generator_single_value", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_multiple_values", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_generators_empty_generator_returns_none_for_every_non_returning_yield_statement", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_set", + "tests/test_serialization.py::TestFieldSerialization::test_list_field_work_with_custom_class_with_iterator_protocol", + "tests/test_serialization.py::TestFieldSerialization::test_bad_list_field", + "tests/test_serialization.py::TestFieldSerialization::test_datetime_integer_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_tuple_field_serialize_none_returns_none", + "tests/test_serialization.py::TestFieldSerialization::test_bad_tuple_field", + "tests/test_serialization.py::TestFieldSerialization::test_serialize_does_not_apply_validators", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialization", + "tests/test_serialization.py::TestFieldSerialization::test_constant_is_always_included_in_serialized_data", + "tests/test_serialization.py::TestFieldSerialization::test_constant_field_serialize_when_omitted", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[String]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Integer]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Boolean]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Float]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Number]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[DateTime]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Time]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Date]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[TimeDelta]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Dict]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Url]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Email]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[UUID]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[Decimal]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IP]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPInterface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv4Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[IPv6Interface]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass20]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass21]", + "tests/test_serialization.py::TestFieldSerialization::test_all_fields_serialize_none_to_none[FieldClass22]", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_value", + "tests/test_serialization.py::TestSchemaSerialization::test_serialize_with_missing_param_callable", + "tests/test_serialization.py::test_serializing_named_tuple", + "tests/test_serialization.py::test_serializing_named_tuple_with_meta", + "tests/test_serialization.py::test_serializing_slice", + "tests/test_serialization.py::test_nested_field_many_serializing_generator", + "tests/test_utils.py::test_missing_singleton_copy", + "tests/test_utils.py::test_get_value_from_object[obj0]", + "tests/test_utils.py::test_get_value_from_object[obj1]", + "tests/test_utils.py::test_get_value_from_object[obj2]", + "tests/test_utils.py::test_get_value_from_object[obj3]", + "tests/test_utils.py::test_get_value_from_namedtuple_with_default", + "tests/test_utils.py::test_get_value_for_nested_object", + "tests/test_utils.py::test_get_value_from_dict", + "tests/test_utils.py::test_get_value", + "tests/test_utils.py::test_set_value", + "tests/test_utils.py::test_is_keyed_tuple", + "tests/test_utils.py::test_is_collection", + "tests/test_utils.py::test_isoformat[value0-2013-11-10T01:23:45]", + "tests/test_utils.py::test_isoformat[value1-2013-11-10T01:23:45.123456+00:00]", + "tests/test_utils.py::test_isoformat[value2-2013-11-10T01:23:45+00:00]", + "tests/test_utils.py::test_isoformat[value3-2013-11-10T01:23:45-06:00]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-expected0]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45+00:00-expected1]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123+00:00-expected2]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45.123456+00:00-expected3]", + "tests/test_utils.py::test_from_iso_datetime[2013-11-10T01:23:45-06:00-expected4]", + "tests/test_utils.py::test_from_iso_time_with_microseconds", + "tests/test_utils.py::test_from_iso_time_without_microseconds", + "tests/test_utils.py::test_from_iso_date", + "tests/test_utils.py::test_from_timestamp[1676386740-expected0]", + "tests/test_utils.py::test_from_timestamp[1676386740.58-expected1]", + "tests/test_utils.py::test_from_timestamp_with_negative_value", + "tests/test_utils.py::test_from_timestamp_with_overflow_value", + "tests/test_utils.py::test_get_func_args", + "tests/test_utils.py::test_function_field_using_type_annotation", + "tests/test_validate.py::test_url_absolute_valid[http://example.org]", + "tests/test_validate.py::test_url_absolute_valid[https://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftp://example.org]", + "tests/test_validate.py::test_url_absolute_valid[ftps://example.org]", + "tests/test_validate.py::test_url_absolute_valid[http://example.co.jp]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/a%C2%B1b]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/~username/]", + "tests/test_validate.py::test_url_absolute_valid[http://info.example.com/?fred]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--mgbh0fb.xn--kgbechtv/]", + "tests/test_validate.py::test_url_absolute_valid[http://example.com/blue/red%3Fand+green]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com/?array%5Bkey%5D=value]", + "tests/test_validate.py::test_url_absolute_valid[http://xn--rsum-bpad.example.org/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_absolute_valid[http://123.45.67.8:8329/]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001:db8::ff00:42]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://[2001::1]:8329]", + "tests/test_validate.py::test_url_absolute_valid[http://www.example.com:8000/foo]", + "tests/test_validate.py::test_url_absolute_valid[http://user@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://user:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://:pass@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://@example.com]", + "tests/test_validate.py::test_url_absolute_valid[http://AZaz09-._~%2A!$&'()*+,;=:@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\\\]", + "tests/test_validate.py::test_url_absolute_invalid[https://example.org\\n]", + "tests/test_validate.py::test_url_absolute_invalid[ftp:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[ftps:///example.com/]", + "tests/test_validate.py::test_url_absolute_invalid[http//example.org]", + "tests/test_validate.py::test_url_absolute_invalid[http:///]", + "tests/test_validate.py::test_url_absolute_invalid[http:/example.org]", + "tests/test_validate.py::test_url_absolute_invalid[foo://example.org]", + "tests/test_validate.py::test_url_absolute_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_absolute_invalid[http://2001:db8::ff00:42:8329]", + "tests/test_validate.py::test_url_absolute_invalid[http://[192.168.1.1]:8329]", + "tests/test_validate.py::test_url_absolute_invalid[abc]", + "tests/test_validate.py::test_url_absolute_invalid[..]", + "tests/test_validate.py::test_url_absolute_invalid[/]", + "tests/test_validate.py::test_url_absolute_invalid[]", + "tests/test_validate.py::test_url_absolute_invalid[None]", + "tests/test_validate.py::test_url_absolute_invalid[http://user@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@pass@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://@@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://^@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%0G@example.com]", + "tests/test_validate.py::test_url_absolute_invalid[http://%@example.com]", + "tests/test_validate.py::test_url_relative_valid[http://example.org]", + "tests/test_validate.py::test_url_relative_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_valid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_valid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_valid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_relative_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_invalid[...]", + "tests/test_validate.py::test_url_relative_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_invalid[]", + "tests/test_validate.py::test_url_relative_invalid[None]", + "tests/test_validate.py::test_url_relative_only_valid[/foo/bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar]", + "tests/test_validate.py::test_url_relative_only_valid[?bar]", + "tests/test_validate.py::test_url_relative_only_valid[/foo?bar#baz]", + "tests/test_validate.py::test_url_relative_only_invalid[http//example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org\\n]", + "tests/test_validate.py::test_url_relative_only_invalid[suppliers.html]", + "tests/test_validate.py::test_url_relative_only_invalid[../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[../.../g]", + "tests/test_validate.py::test_url_relative_only_invalid[...]", + "tests/test_validate.py::test_url_relative_only_invalid[\\\\]", + "tests/test_validate.py::test_url_relative_only_invalid[]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.org]", + "tests/test_validate.py::test_url_relative_only_invalid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/foo/bar/../baz]", + "tests/test_validate.py::test_url_relative_only_invalid[https://example.com/../icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/./icons/logo.gif]", + "tests/test_validate.py::test_url_relative_only_invalid[ftp://example.com/../../../../g]", + "tests/test_validate.py::test_url_relative_only_invalid[http://example.com/g?y/./x]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.org]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://123.45.67.8/]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example.]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example:80]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://user.name:pass.word@example]", + "tests/test_validate.py::test_url_dont_require_tld_valid[http://example/foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http//example]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://example\\n]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http://.example.org]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[http:///foo/bar]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[]", + "tests/test_validate.py::test_url_dont_require_tld_invalid[None]", + "tests/test_validate.py::test_url_custom_scheme", + "tests/test_validate.py::test_url_relative_and_custom_schemes", + "tests/test_validate.py::test_url_custom_message", + "tests/test_validate.py::test_url_repr", + "tests/test_validate.py::test_url_rejects_invalid_relative_usage", + "tests/test_validate.py::test_email_valid[niceandsimple@example.com]", + "tests/test_validate.py::test_email_valid[NiCeAnDsImPlE@eXaMpLe.CoM]", + "tests/test_validate.py::test_email_valid[very.common@example.com]", + "tests/test_validate.py::test_email_valid[a.little.lengthy.but.fine@a.iana-servers.net]", + "tests/test_validate.py::test_email_valid[disposable.style.email.with+symbol@example.com]", + "tests/test_validate.py::test_email_valid[\"very.unusual.@.unusual.com\"@example.com]", + "tests/test_validate.py::test_email_valid[!#$%&'*+-/=?^_`{}|~@example.org]", + "tests/test_validate.py::test_email_valid[niceandsimple@[64.233.160.0]]", + "tests/test_validate.py::test_email_valid[niceandsimple@localhost]", + "tests/test_validate.py::test_email_valid[jos\\xe9@blah.com]", + "tests/test_validate.py::test_email_valid[\\u03b4\\u03bf\\u03ba.\\u03b9\\u03bc\\u03ae@\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1.\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae]", + "tests/test_validate.py::test_email_invalid[niceandsimple\\n@example.com]", + "tests/test_validate.py::test_email_invalid[NiCeAnDsImPlE@eXaMpLe.CoM\\n]", + "tests/test_validate.py::test_email_invalid[a\"b(c)d,e:f;gi[j\\\\k]l@example.com]", + "tests/test_validate.py::test_email_invalid[just\"not\"right@example.com]", + "tests/test_validate.py::test_email_invalid[user@example]", + "tests/test_validate.py::test_email_invalid[@nouser.com]", + "tests/test_validate.py::test_email_invalid[example.com]", + "tests/test_validate.py::test_email_invalid[user]", + "tests/test_validate.py::test_email_invalid[]", + "tests/test_validate.py::test_email_invalid[None]", + "tests/test_validate.py::test_email_custom_message", + "tests/test_validate.py::test_email_repr", + "tests/test_validate.py::test_range_min", + "tests/test_validate.py::test_range_max", + "tests/test_validate.py::test_range_custom_message", + "tests/test_validate.py::test_range_repr", + "tests/test_validate.py::test_length_min", + "tests/test_validate.py::test_length_max", + "tests/test_validate.py::test_length_equal", + "tests/test_validate.py::test_length_custom_message", + "tests/test_validate.py::test_length_repr", + "tests/test_validate.py::test_equal", + "tests/test_validate.py::test_equal_custom_message", + "tests/test_validate.py::test_equal_repr", + "tests/test_validate.py::test_regexp_str", + "tests/test_validate.py::test_regexp_compile", + "tests/test_validate.py::test_regexp_custom_message", + "tests/test_validate.py::test_regexp_repr", + "tests/test_validate.py::test_predicate", + "tests/test_validate.py::test_predicate_custom_message", + "tests/test_validate.py::test_predicate_repr", + "tests/test_validate.py::test_noneof", + "tests/test_validate.py::test_noneof_custom_message", + "tests/test_validate.py::test_noneof_repr", + "tests/test_validate.py::test_oneof", + "tests/test_validate.py::test_oneof_options", + "tests/test_validate.py::test_oneof_text", + "tests/test_validate.py::test_oneof_custom_message", + "tests/test_validate.py::test_oneof_repr", + "tests/test_validate.py::test_containsonly_in_list", + "tests/test_validate.py::test_contains_only_unhashable_types", + "tests/test_validate.py::test_containsonly_in_tuple", + "tests/test_validate.py::test_contains_only_in_string", + "tests/test_validate.py::test_containsonly_custom_message", + "tests/test_validate.py::test_containsonly_repr", + "tests/test_validate.py::test_containsnoneof_error_message", + "tests/test_validate.py::test_containsnoneof_in_list", + "tests/test_validate.py::test_containsnoneof_unhashable_types", + "tests/test_validate.py::test_containsnoneof_in_tuple", + "tests/test_validate.py::test_containsnoneof_in_string", + "tests/test_validate.py::test_containsnoneof_custom_message", + "tests/test_validate.py::test_containsnoneof_mixing_types", + "tests/test_validate.py::test_and", + "tests/test_version_attributes.py::test_version_attributes_deprecated" + ] +} diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/grade.py b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/panel-config.json b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..4bf890f0f751992d624ac06850df63d8766c0b4d --- /dev/null +++ b/tasks/marshmallow-code__marshmallow.9716fc62.combine_file__x2xypft4/tests/panel-config.json @@ -0,0 +1,23 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install -e '.[tests]'" + ], + "test_dependency_source_sha256": { + "pyproject.toml": "4045b42c920dc27cbad93c32b2369d839181b4b77214f0f851d81693514927bd", + "tox.ini": "0d99297b2998a7fa3090bc8142f556aab6902d04a8053953ce11938253193877" + } +}